【发布时间】:2011-11-26 15:17:39
【问题描述】:
我的 MySQL 数据库在 customer_customer 表中有 30 行。其中 5 条记录的 adm_name 为 Mike。
mysql> select id from customer_customer where adm_name like '%mike%';
+----+
| id |
+----+
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
+----+
5 rows in set (0.00 sec)
现在我已将表格的字符集更改为 utf8
mysql> ALTER TABLE customer_customer CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 30 rows affected (0.03 sec)
Records: 30 Duplicates: 0 Warnings: 0
如果我再次运行类似查询,那么 MySQL 不会返回任何记录。
mysql> select id from customer_customer where adm_name like '%mike%';
Empty set (0.00 sec)
我无法理解这种行为。有没有人遇到过这种情况?我做错什么了吗?
【问题讨论】:
-
通过查看类似的帖子stackoverflow.com/questions/2150256/…,如果我将 COLLATE 更改为 utf8_unicode_ci 那么查询工作正常。
-
因为 CI 表示不区分大小写的比较。