Postgres Case Insensitive in IN operator?

2.9k Views Asked by At

My Sample Sql is

select * from fruits where name in ('Orange','grape','APPLE','ManGO',etc....);//

Is possible to include ilike or ~* in IN Operator in Postgres?

My solution is

select * from fruits where upper(name) in 
(upper('Orange'),upper('grape'),upper('APPLE'),upper('ManGO'),etc....);

i think it is not correct method, Please let me know any optimal solution for this case

1

There are 1 best solutions below

0
On BEST ANSWER

You can try to use ILIKE with ANY

SELECT * 
FROM fruits 
WHERE name ILIKE ANY(array['Orange', 'grape', 'APPLE', 'ManGO']);

sqlfiddle