利用 set names 'gbk' 解决 '鼠' 与 ‘弱’ ‘试’ 相同 的问题
http://topic.csdn.net/u/20081204/13/841fbb19-7ca0-439d-b353-e6578ac98365.html
这个可以归结为典型的字符集问题. 将字符集都设成一致的情况下,不至于出错。
请看:
mysql> show variables like 'char%';
+--------------------------+-------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | gbk |
| character_set_results | latin1 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | d:\mysql-5.0.9-beta-win32\share\charsets/ |
+--------------------------+-------------------------------------------+
7 rows in set (0.01 sec)
mysql> set names 'gbk';
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like 'char%';
+--------------------------+-------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | d:\mysql-5.0.9-beta-win32\share\charsets/ |
+--------------------------+-------------------------------------------+
7 rows in set (0.00 sec)
mysql> select * from a1;
+------+
| word |
+------+
| 鼠 |
| 试 |
+------+
2 rows in set (0.00 sec)
mysql> delete from a1;
Query OK, 2 rows affected (0.02 sec)
mysql> insert into a1 values('鼠');
Query OK, 1 row affected (0.06 sec)
mysql> insert into a1 values('试');
Query OK, 1 row affected (0.08 sec)
mysql> select * from a1 where word='鼠';
+------+
| word |
+------+
| 鼠 |
+------+
1 row in set (0.01 sec)
这样做是不会有问题的。有兴趣可以一试。
至于binary like似乎说的是另一种匹配方式。