Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making QUERY function case insensitive

=QUERY(D4:F385;"select D,F where D contains '"&J4&"'")  

If in J4 cell we have tree, this query grabs cells containing tree, but not Tree.

How to make it case insensitive?

like image 504
Andrew Anderson Avatar asked Sep 21 '15 10:09

Andrew Anderson


People also ask

How do you make a case insensitive in SQL query?

column LIKE 'ABC' or column LIKE 'aBc' will return FALSE for such comparison. To do a case-insensitive comparison, use the ILIKE keyword; e.g., column ILIKE 'aBc' and column ILIKE 'ABC' both return TRUE for 'abc' . In contrast, MySQL and MS SQL Server have case-insensitive behaviors by default.

Are query functions case sensitive?

For your information, almost all of the functions in Google Sheets are case insensitive. But there are exceptions like QUERY, EXACT, and FIND functions, which are case sensitive.

How do you make a case insensitive like a query in MySQL?

When searching for partial strings in MySQL with LIKE you will match case-insensitive by default*. If you want to match case-sensitive, you can cast the value as binary and then do a byte-by-byte comparision vs. a character-by-character comparision. The only thing you need to add to your query is BINARY .

Would you make a case insensitive query in MySQL?

The default collations used by SQL Server and MySQL do not distinguish between upper and lower case letters—they are case-insensitive by default. The logic of this query is perfectly reasonable but the execution plan is not: DB2.


1 Answers

The answer is unfortunately not complete, because now it will only work with "tree", but not with "Tree" or with "TREE". The correct solution would be to render always lower also the reference, as in:

=QUERY(D4:F385;"select D,F where LOWER(D) contains '"&lower(J4)&"'"
like image 145
Luca Avatar answered Sep 23 '22 07:09

Luca