现在数据库存在name=abc,不存在name=ABC的
但是直接查询是都能查到abc数据的
select * from user where name='abc'
select * from user where name='ABC'
第一种方法:
select * from user where binary name='abc'
select * from user where binary name='ABC'
第二种方法:
在建表时时候加以标识
create table user(name char(20) binary)
原理:
对于CHAR、VARCHAR和TEXT类型,BINARY属性可以为列分配该列字符集的 校对规则。
BINARY属性是指定列字符集的二元 校对规则的简写。
排序和比较基于数值字符值。因此也就自然区分了大小写。