mysql 中的like查找不忽略大小写

like默认情况下是忽略大小写的,但是加上collate latin1_general_cs就可以避免这种情况了

例子如下:

The following two statements illustrate that string comparisons are not case sensitive unless one of the operands is a case sensitive (uses a case-sensitive collation or is a binary string):

 
 
   
   
   
   
mysql> SELECT 'abc' LIKE 'ABC'; -> 1 mysql> SELECT 'abc' LIKE _latin1 'ABC' COLLATE latin1_general_cs; -> 0 mysql> SELECT 'abc' LIKE _latin1 'ABC' COLLATE latin1_bin; -> 0 mysql> SELECT 'abc' LIKE BINARY 'ABC'; -> 0

你可能感兴趣的:(数据库)