MySQL sorting Chinese details and examples

MySQL sorting Chinese details and examples

Detailed explanation of MySQL sorting Chinese characters

By default, MySQL only supports sorting of dates, times, and English strings. If you use order by on Chinese characters, you may not get the desired results. For example, the following query will not sort by the pinyin of Chinese characters as we want:

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 sort according to the pinyin of Chinese:

SELECT * from user order by CONVERT(user_name USING GBK);

Thank you for reading, I hope it can help you, thank you for your support of this site!

You may also be interested in:
  • UTF8 Chinese sorting example code in PHP and MYSQL
  • Example of Chinese sorting in UTF8 encoding in PHP and MYSQL
  • How to sort mysql in Chinese
  • How to make MySQL support Chinese sorting
  • MySQL Chinese sorting precautions and implementation methods

<<:  Linux command line quick tips: How to locate a file

>>:  In-depth understanding of javascript class array

Recommend

Troubleshooting MySQL high CPU load issues

High CPU load caused by MySQL This afternoon, I d...

Install MySQL (including utf8) using Docker on Windows/Mac

Table of contents 1. Docker installation on Mac 2...

How to output Chinese characters in Linux kernel

You can easily input Chinese and get Chinese outp...

How to use nginx to simulate blue-green deployment

This article introduces blue-green deployment and...

Introduction to HTML basic controls_PowerNode Java Academy

The <input> tag The <input> tag is us...

Getting Started: A brief introduction to HTML's basic tags and attributes

HTML is made up of tags and attributes, which are...

Detailed explanation of CSS3 rotating cube problem

3D coordinate concept When an element rotates, it...

Build a high-availability MySQL cluster with dual VIP

Table of contents 1. Project Description: 2. Proj...

Parsing MySQL binlog

Table of contents 1. Introduction to binlog 2. Bi...

Detailed explanation of Vue router routing

Table of contents 1. Basic use 2. Several points ...

How to configure Linux to use LDAP user authentication

I am using LDAP user management implemented in Ce...

How to handle super large form examples with Vue+ElementUI

Recently, due to business adjustments in the comp...

Docker implements re-tagging and deleting the image of the original tag

The docker image id is unique and can physically ...