mysql查询不区分大小写,加上binary就可以了,如:select * from users where binary nickname=?
第一种:让mysql查询时区分大小写
select * from usertable where binary id = 'AAMkADExM2M5NjQ2LWUzYzctNDFkMC1h';
第二种:在建表时加以标识
create table table_name {
id varchar(32) binary;
}
在mysql中,存在大小写问题的地方还有:
(1) 关键字: 不区分大小写 select * fRom table_name 和 select * from table_name 效果是一样的
(2) 标示符(如数据库名称和表名称):不区分大小写。如存在表users,那么select * from users和select * from uSers 效果一样。网上说这跟操作系统有关,在所有Unit操作系统(除了使用HFS+的Mac OS 之外)上都是区分大小写的,而在windows上是不区分大小写的。(网上的这一说法没有验证过,我在windows server2003上是不区分大小写的)
(3) 表的别名:不区分大小写 select m.* from users m where M.username = 'aa';
(4) 列的别名:不区分大小写 select uName from (select username as uname from users where id = 768) t