mysql sort by Chinese pinyin alphabetical order

When mysql builds databases and tables, it usually uses UTF-8 encoding ( utf8_general_ci), that is, all fields, whether Chinese or English, are UTF8 encoding. At this time, the Chinese fields are sorted by the initials of pinyin, using the following way to:

order by  CONVERT( trait_cn USING gbk )  asc

 

If it is the default iso-8859 ( latin1_swedish_ci) encoding, use the following method:

order by binary(trait_cn) asc

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326357916&siteId=291194637