MySQL sort by pinyin of Chinese characters (turn)

Source: Internet
Author: User

According to the phonetic sorting of Chinese characters, the comparison is more in the sort of the name, according to the phonetic Alphabet of the surname, from A to Z sort;

If the name of the field is stored in the GBK character set, that would be good, because the GBK code encoding itself using the phonetic sorting method (commonly used first-class Chinese characters 3,755 Pinyin sorting, two-level Chinese characters are not, but considering the names of people are commonly used Chinese characters, Therefore, it is sufficient to sort the first-level Chinese characters correctly.

Add order BY name ASC directly after the query statement; The query results are sorted in ascending order of last name;

If the field that stores the name is in the UTF8 character set, you need to transcode the field at sort time; for the code is Order by convert (name using GBK) ASC; Similarly, the results of the query are sorted in ascending order of the last name;

MySQL sort by pinyin of Chinese characters (turn)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.