How do you combine NOT IN
and LIKE
?
Let's assume we have a table that contains a column of names (something like 'blue cheese', 'gouda cheese' and so on) and I want to select all the names that doesn't contain 'cheese', 'milk', 'meat'.
As far as I understand to look for something that is not in an array of strings you use NOT IN
and the pass the strings
SELECT names FROM some_table NOT IN('cheese','milk','meat');
but how do I pass
LIKE '%cheese%'
to it?
The construct
LIKE ANY (ARRAY[...])
appears to meet your needs;You need the wildcard characters if you want to use
LIKE
this way. If you really just want equality, you can use: