MySQL Sort by Chinese name sql code www.2cto.com /* navicat MySQL Data Transfer source Server : local source Server version:50022 source Host &NBS P : localhost:3306 source Database : Test target Server Type : MYS QL target Server version:50022 file Encoding : 65001 date:201 2-11-19 15:46:13 */ set foreign_key_checks=0; ------------------------------ --Table structure for ' person ' ----------------------- ------- drop TABLE IF EXISTS ' person '; create TABLE ' person ' ( ' id ' int (ten) unsigned not NULL auto_increment, ' name ' varchar (20) Default NULL, PRIMARY KEY (' id ') ) engine=innodb default Charset=utf8; ------------------------------ --ReCords of person ------------------------------ insert to ' person ' VALUES (' 1 ', ' Zhang San '); insert into ' person ' VALUES (' 2 ', ' John Doe '); insert into ' person ' VALUES (' 3 ', ' Harry '); insert into ' person ' VALUES (' 4 ', ' Caifan '); insert into ' person ' VALUES (' 5 ', ' money Seven '); Positive Order: select * from Person ORDER by CONVERT (name USING GBK); Results: 2John Doe4Caifan5Money Seven3Harry1Zhang SanReverse: SELECT * from Person ORDER by CONVERT (name USING GBK) desc Result: 1Zhang San3Harry5Money Seven4Caifan2John Doe
MySQL Sorted by Chinese name