I'm trying to get rows where a column of type text[]
contains a value similar to some user input.
What I've thought and done so far is to use the 'ANY'
and 'LIKE
' operator like this:
select * from someTable where '%someInput%' LIKE ANY(someColum);
But it doesn't work. The query returns the same values as that this query:
select * from someTable where 'someInput' = ANY(someColum);
I've got good a result using the unnest()
function in a subquery but I need to query this in WHERE
clause if possible.
Why doesn't the LIKE
operator work with the ANY
operator and I don't get any errors? I thought that one reason should be that ANY
operator is in the right-hand of query, but ...
Is there any solution to this without using unnest()
and if it is possible in WHERE
clause?
unnest
would be to properly normalize your data model.