当表中存在变音符号时,“SELECT”选择错误的行

时间:2013-02-06 13:03:50

标签: mysql utf-8

表'textconstraint'(collat​​ion utf8_general_ci)的结构如下:

+-----+---------+
| id  | pattern |
+-----+---------+
|  11 | Ä       |
|  27 | A       |
+-----+---------+

当我查询

SELECT * FROM textconstraint WHERE pattern = 'A' LIMIT 1;

选择以下行

+----+---------+
| id | pattern |
+----+---------+
| 11 | Ä       |
+----+---------+

为什么选择A-umlaut代替A

P.S。我做SET NAMES UTF8

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

SELECT *
FROM textconstraint
WHERE pattern = BINARY 'A'

请参阅this fiddle