Home >Database >Mysql Tutorial >Detailed explanation and examples of MySQL sorting Chinese
This article mainly introduces the detailed explanation and examples of MySQL's sorting of Chinese. Friends in need can refer to the following
MySQL's detailed explanation of sorting Chinese
MySQL only supports sorting date, time and English strings by default. If you order by for Chinese, you may not get the desired results. For example, the following query will not sort according to the pinyin of Chinese characters as we think. :
SELECT * from user order by user_name;
If you want to sort relative to Chinese, you can use CONVERT (coloum_name USING GBK) to convert Chinese to GBK encoding, and then sort, you can achieve the sorting based on Hanzi Sort by pinyin:
SELECT * from user order by CONVERT(user_name USING GBK);
The above is the detailed content of Detailed explanation and examples of MySQL sorting Chinese. For more information, please follow other related articles on the PHP Chinese website!