How does mysql sort the solution according to Chinese
- 2020-05-14 05:06:47
- OfStack
Sql code
Positive sequence:
Results:
2 li 4
4 the horse 6
5 money 7
3 the king 5
1 3
Reverse order:
Results:
1 3
3 the king 5
5 money 7
4 the horse 6
2 li 4
/*
Navicat MySQL Data Transfer
Source Server : local
Source Server Version : 50022
Source Host : localhost:3306
Source Database : test
Target Server Type : MYSQL
Target Server Version : 50022
File Encoding : 65001
Date: 2012-11-19 15:46:13
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `person`
-- ----------------------------
DROP TABLE IF EXISTS `person`;
CREATE TABLE `person` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(20) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of person
-- ----------------------------
INSERT INTO `person` VALUES ('1', ' zhang 3');
INSERT INTO `person` VALUES ('2', ' li 4');
INSERT INTO `person` VALUES ('3', ' The king 5');
INSERT INTO `person` VALUES ('4', ' The horse 6');
INSERT INTO `person` VALUES ('5', ' money 7');
Positive sequence:
select * from person ORDER BY CONVERT(name USING gbk);
Results:
2 li 4
4 the horse 6
5 money 7
3 the king 5
1 3
Reverse order:
select * from person ORDER BY CONVERT(name USING gbk) desc
Results:
1 3
3 the king 5
5 money 7
4 the horse 6
2 li 4