mysql查询默认是不区分大小写的 如:
1
2
|
select
*
from
some_table
where
str=‘abc
';
select * from some_table where str='
ABC';
|
得到的结果是一样的,如果我们需要进行区分的话可以按照如下方法来做:
第一种方法:
要让mysql查询区分大小写,可以:
1
2
|
select
*
from
some_table
where
binary
str=
'abc'
select
*
from
some_table
where
binary
str=
'ABC'
|
第二方法:
在建表时时候加以标识
1
2
3
|
create table some_table(
str
char
(20) binary
)
|