Select query in MySQL can be either case sensitive or case insensitive by default.
It depends on CHARSET defined while creating the table. Binary chartset(e.g utf8) will make select query case sensitive by default. But anyway we can force the select query case insensitive by using UCASE in the query.
e.g select * from companys where ucase(name)=ucase('QualityPoint')
More Articles...
Shop at Rajamanickam.com | Birthday Gift Idea? | Hire me for $6 per Hour
Get 3 useful ebooks for Rs 99 in India and $5.99 globally
Get a 75% commission | ChatGPT and and Google Gemini for Beginners (Use Discount code QPT)
Search This Blog
Art of Talking to AI | Tech eBook | Dream Big | Listen to Dream Big
Today's Deals | Timesheet | Products | 3 ebooks for $5.99 / Rs 99 | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
Today's Deals | Timesheet | Products | 3 ebooks for $5.99 / Rs 99 | Earn 50% commission
About | Privacy | Follow | TOS | WhatsApp | Contact
I may earn a commission from Amazon affiliate links
2 comments:
Actually, it depends on the collation of the column or expression, not the character set. Collations are related to character sets, and binary collations are case sensitive, as are columns of the (VAR)BINARY data type.
For example:
mysql> select "equals" = "EQUALS";
+---------------------+
| "equals" = "EQUALS" |
+---------------------+
| 1 |
+---------------------+
1 row in set (0.00 sec)
versus
mysql> select "equals" = "EQUALS" collate latin1_bin;
+----------------------------------------+
| "equals" = "EQUALS" collate latin1_bin |
+----------------------------------------+
| 0 |
+----------------------------------------+
1 row in set (0.35 sec)
or
mysql> select "equals" = cast("EQUALS" as BINARY);
+-------------------------------------+
| "equals" = cast("EQUALS" as BINARY) |
+-------------------------------------+
| 0 |
+-------------------------------------+
1 row in set (0.00 sec)
Justin Swanhart,
Thanks for your explanation.
Post a Comment