Lets say I have an array of strings returned by some subquery. And I want to make sure that at least one of the elements is matching with string (for example: ILIKE "%alex%"). What should I do for that? My code:
ANY(ARRAY["Alexander", "Michael", "John"]) ILIKE "%alex%"
is not working at all. I need a solution which will return true in my case, because one of the elements(Alexander) is ILIKE "%alex%".
One approach is to use exists:
where exists (select 1 from unnest(ARRAY['Alexander', 'Michael', 'John']) el where el ILIKE '%alex%')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With