即使整理是正确的,MySQL也不会对瑞典字符ORäö不起作用

时间:2012-12-04 15:19:06

标签: mysql collation

此查询:

SELECT customer_id, customer_name FROM customers WHERE isActive = '1' ORDER BY customer_name ASC

输出:

+-------------+-----------------------+
| customer_id | customer_name         |
+-------------+-----------------------+
|           1 | Äname                 |
|           2 | Aname                 |
|           3 | Bname                 |
+-------------+-----------------------+

为什么它不对特殊的瑞典字符进行排序,即使我有排序utf8_swedish_ci

SHOW TABLE STATUS FROM myDatabase WHERE name = 'customers';

+-------------+----------------------------+
| Name        | Engine   | Collation       |
+-------------+----------------------------+
| customers   | MyISAM   | utf8_swedish_ci |
+-------------+----------------------------+

我甚至试图将整理放在我的查询中:

SELECT * FROM customers WHERE isActive = 1 COLLATE utf8_swedish_ci ORDER BY customer_name ASC

但后来我得到了:

Error Code: 1253. COLLATION 'utf8_swedish_ci' is not valid for CHARACTER SET 'binary'

1 个答案:

答案 0 :(得分:4)

不知道默认行为,但the correct syntax是:

SELECT customer_id, customer_name
FROM customers
WHERE isActive = '1'
ORDER BY customer_name COLLATE utf8_swedish_ci ASC