为此,您可以使用COLLATE。以下是语法-
select *from yourTableName where yourColumnName LIKE yourValue COLLATE utf8_bin;
让我们首先创建一个表-
mysql> create table DemoTable ( LastName varchar(100) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('Brown'); mysql> insert into DemoTable values('BROWN'); mysql> insert into DemoTable values('brown'); mysql> insert into DemoTable values('BRoWN');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
输出结果
+----------+ | LastName | +----------+ | Brown | | BROWN | | brown | | BRoWN | +----------+ 4 rows in set (0.00 sec)
以下是COLLATE的查询-
mysql> select *from DemoTable where LastName LIKE 'BROWN' COLLATE utf8_bin;
输出结果
+----------+ | LastName | +----------+ | BROWN | +----------+ 1 row in set (0.00 sec)