MySQL simple example of sorting Chinese characters by pinyin

MySQL simple example of sorting Chinese characters by pinyin

If the field storing the name uses the GBK character set, then it will be easy to deal with, because the GBK internal code itself uses the pinyin sorting method when encoding (the 3755 commonly used first-level Chinese characters are sorted by pinyin, while the second-level Chinese characters are not, but considering that people's names are commonly used Chinese characters, it is sufficient to just sort the first-level Chinese characters correctly).

Directly add order by name asc after the query statement; the query results are sorted in ascending order by last name;

If the field storing the name uses the utf8 character set, the field needs to be converted when sorting; the code is order by convert(name using gbk) asc; Similarly, the query results are sorted in ascending order by last name;

The above simple example of MySQL sorting according to the pinyin of Chinese characters is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Two methods to sort Chinese data in MySQL by pinyin
  • How to sort mysql by the first letter of Chinese characters
  • How to sort mysql in Chinese

<<:  js to achieve interesting countdown effect

>>:  Solution to the welcome to emergency mode message when booting CentOS7.4

Recommend

UDP DUP timeout UPD port status detection code example

I have written an example before, a simple UDP se...

Detailed explanation of three ways to import CSS files

There are three ways to introduce CSS: inline sty...

JavaScript implements simple calculator function

This article example shares the specific code of ...

Detailed explanation of single-row function code of date type in MySQL

Date-type single-row functions in MySQL: CURDATE(...

XHTML introductory tutorial: text formatting and special characters

<br />This section introduces how to impleme...

Detailed explanation of the flexible use of CSS grid system in projects

Preface CSS grids are usually bundled in various ...

WEB standard web page structure

Whether it is the background image or the text siz...

MySQL Query Cache Graphical Explanation

Table of contents 1. Principle Overview Query Cac...

Design and implementation of Vue cascading drop-down box

Table of contents 1. Database design 2. Front-end...

Several ways to solve CSS style conflicts (summary)

1. Refine the selector By using combinators, the ...

Vue close browser logout implementation example

Table of contents 1. beforeunload event 2. Unload...