Home > Database > Mysql Tutorial > mysql如何按照中文排序解决方案_MySQL

mysql如何按照中文排序解决方案_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:23:16
Original
1290 people have browsed it

bitsCN.com Sql代码

/*
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', '张三');
INSERT INTO `person` VALUES ('2', '李四');
INSERT INTO `person` VALUES ('3', '王五');
INSERT INTO `person` VALUES ('4', '马六');
INSERT INTO `person` VALUES ('5', '钱七');

正序:

select * from person ORDER BY CONVERT(name USING gbk);

结果:
2 李四
4 马六
5 钱七
3 王五
1 张三

倒序:

select * from person ORDER BY CONVERT(name USING gbk) desc

结果:
1 张三
3 王五
5 钱七
4 马六
2 李四bitsCN.com

Related labels:
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
Latest Issues
php - localhost shows 404
From 1970-01-01 08:00:00
0
0
0
php - localhost cannot access a certain folder
From 1970-01-01 08:00:00
0
0
0
localhost and 127.0.0.1
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template