I have a table with a field containing an array of strings (type is character varying(255)[]
).
I'd like to compare a given string with a wildcard, say 'query%'
, to any of the elements of this field.
This request works and gets back the expected results:
SELECT * FROM my_table WHERE 'query' ILIKE ANY(my_field)
But with the wildcard, I got no results:
SELECT * FROM my_table WHERE 'query%' ILIKE ANY(my_field)
I think the reason is that the wildcard is supported only at the right side of the ILIKE
operator, but ANY(my_field)
also has to be after the operator.
Is there a way to achieve what I want?
Using PostgreSQL 9.5.