Problem sorting Swedish characters Å Ä Ö MySQL

后端 未结 3 1043
臣服心动
臣服心动 2020-12-16 03:00

I\'m trying to sort a list with asc or desc - depending on what the user choose. In the list I have the Swedish characters Å Ä Ö and it\'s here the problem shows up. I have

相关标签:
3条回答
  • 2020-12-16 03:29

    The general collation places Ö with O. If you want Ö at the end of the alphabet then you need to use utf8_swedish_ci.

    0 讨论(0)
  • 2020-12-16 03:29

    If you want to convert existing tables to a new collation, just use the following:

    alter table [tableName] convert to character set utf8 collate utf8_swedish_ci;
    
    0 讨论(0)
  • 2020-12-16 03:35

    My database and the field that the value is in have the collation utf8_general_ci, so that is'nt the problem

    But it is. :) Different collations have different sort orders, and different ways how they interpret umlauts.

    utf8_general_ci will sort Ö with O. Try the utf8_swedish_ci instead. That will have the correct sorting order, which (IIRC) is that ÄAÖ go to the end of the alphabet.

    For background info, see 9.1.7.8. Examples of the Effect of Collation

    0 讨论(0)
提交回复
热议问题