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

2
  • 2
    Another duplicate with explanation of why it doesn't work: stackoverflow.com/questions/34657669/… Commented May 4, 2018 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... Commented May 6, 2018 at 13:35

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.