Something like:
SELECT * FROM table WHERE something IN ('{"val1","val2"}'::text[]);
I tried it with array_to_string().
SELECT * FROM table WHERE something IN (array_to_string('{"val1","val2"}'::text[]));
But I guess that makes it to this:
SELECT * FROM table WHERE something IN ('val1,val2'); --one single string
I guess the single values must also be surrounded with apostrophes.
Is that possible somehow, or can it be solved in a completely different way?
2
Answers
Use the ANY operator:
You are looking for
ANY
:But if you insist on using
IN
, you can achieve the same withUNNEST
:(online demo)