Home > Database > Mysql Tutorial > body text

Detailed explanation and examples of MySQL sorting Chinese

巴扎黑
Release: 2017-05-14 14:17:17
Original
1269 people have browsed it

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;
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!