该查询:
在isActive =’1’的情况下从客户中选择customer_id,customer_name或按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'
解决方法:
不知道默认行为,但是the correct syntax是:
SELECT customer_id, customer_name
FROM customers
WHERE isActive = '1'
ORDER BY customer_name COLLATE utf8_swedish_ci ASC