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?
This question is related to
postgresql
postgresql-9.2
SELECT * FROM table WHERE arr && '{s}'::text[];
Compare two arrays for containment.
Note that this may also work:
SELECT * FROM table WHERE s=ANY(array)
Source: Stackoverflow.com