How to make a select with array contains value clause in psql
I have column arr which is of type array . I need to get rows, where arr column contains value s This query: SELECT * FROM table WHERE arr @> ARRAY['s'] gives the error: ERROR: operator does not exist: character varying[] @> text[] Why does it not work? p.s. I know about any() operator, but why doesn't @> work? Wojtas Try SELECT * FROM table WHERE arr @> ARRAY['s']::varchar[] Note that this may also work: SELECT * FROM table WHERE s=ANY(array) SELECT * FROM table WHERE arr && '{s}'::text[]; Compare two arrays for containment. 来源: https://stackoverflow.com/questions/16606357/how-to-make-a