Ordering non-english letters in MySQL

不问归期 提交于 2021-02-08 10:22:52

问题


I have a client who just sent me the following in regards to order their letters. They are from Finland.

In our alphabet the letters å, ä and ö are at the very end of the alphabet. Therefore names starting with those should also be after the letter z, not under "a" or "o".

This is the first I've heard of this. Is there a way I could make these letters show at the end of a alphabetical list using MySQL?


回答1:


That's probably the collation of that table is utf8_general_ci. Try this,

SELECT..
FROM..
WHERE..
ORDER BY text COLLATE utf8_bin
  • SQLFiddle DEMO (utf8_bin vs utf8_general_ci)



回答2:


You need to pick a collation that fits your ordering and encoding requirements. A list of them can be fetched with:

SHOW COLLATION

You should be able to set the collation on your connection, and tables and associated data can also be set with defaults. Some statements also support specifying the collation for ordering purposes.

I remember utf8_swedish_ci being the default for a long time presumably because MySQL was created by a Finn while working in Sweden. Later that was changed to utf8_general_ci to be more neutral.




回答3:


Best use ASCII coding/indexing as multilingual www.qfree.com.au can be any language display



来源:https://stackoverflow.com/questions/13410609/ordering-non-english-letters-in-mysql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!