2

I have a column tags, which is of type text array TEXT[]. I can use the following query to retrieve rows that contain certain tags from the database:

SELECT * FROM records  WHERE ('foobar' = ANY (tags));

This query retrieves all rows that contain a foobar tag. This works fine.

Now, I'm in a situation where I need to search the tags arrays for sub-strings. I tried the LIKE operator with this query:

SELECT * FROM records  WHERE ('%oo%' LIKE ANY (tags));

But it doesn't seem to work. Does anyone know how to achieve this?

I'm using Postgresql 10.3

Rotareti
  • 49,483
  • 23
  • 112
  • 108
  • 2
    Another duplicate with explanation of why it doesn't work: https://stackoverflow.com/questions/34657669/postgresql-text-array-contains-value-similar-to – JGH May 04 '18 at 13:55
  • @JGH This should be the marked duplicate link. I'm glad you posted it, since the one that LaurenzAlbe posted doesn't help me at all... – Rotareti May 06 '18 at 13:35

0 Answers0