gpt4 book ai didi

MySQL 不会按瑞典字符排序 åäö 即使排序正确也无法正常工作

转载 作者:可可西里 更新时间:2023-11-01 08:06:32 27 4
gpt4 key购买 nike

这个查询:

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'

最佳答案

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

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

关于MySQL 不会按瑞典字符排序 åäö 即使排序正确也无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13706099/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com