0

I have column array[] named tags.

i have here f.e.:

{{dogs, cats, phones, bottles}}
{{pistols,politican,juices}}
{{dogs,pistols}}
etc..

I want to find in all of them f.e. word "dogs" and select only entries with "dogs". I tried to use:

SELECT * FROM question WHERE tags[0] = ANY(ARRAY['dogs']);
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
Kamil
  • 782
  • 1
  • 9
  • 24

1 Answers1

4

You need to do it the other way round:

SELECT * 
FROM question 
WHERE 'dogs' = ANY(tags);

The above assumes that tags is a one-dimensional array, e.g. text[]