MySQL 能执行哪种类型的字符串比较(区分大小写还是不区分大小写)?
比较字符时,MySQL 无法执行区分大小写的比较。下面是表 “Employee” 中的数据,可以使用此示例来说明 -
mysql> Select * from Employee; +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 2 | Rahul | 20000 | | 3 | Advik | 25000 | | 4 | Aarav | 65000 | | 5 | Ram | 20000 | | 6 | Mohan | 30000 | | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+--------+--------+ 8 rows in set (0.09 sec)
以下查询的结果集表明 MySQL 在比较字符时不区分大小写。
mysql> Select * from Employee WHERE Name IN ('gaurav','RAM'); +----+--------+--------+ | ID | Name | Salary | +----+--------+--------+ | 1 | Gaurav | 50000 | | 5 | Ram | 20000 | +----+--------+--------+ 2 rows in set (0.00 sec)
广告