当前位置:网站首页>MySQL排序
MySQL排序
2022-07-25 09:16:00 【很菜的萝卜】
1,基本的DESC、ASC排序
select * from tableName order by columnName1 desc,columnName2 asc;
2,中文排序。MySQL查询对大小写不敏感,一般都用ISO-8859作为默认的字符集。所以就没有办法正确比较中文编码的字符。有两个办法可以解决:
1. 在建表时,包含中文字符的字段加上"binary"属性。例:name varchar(5) binary。
2. 在查询时强制MySQL使用指定的字符来进行查询,关键字"convert()"。例:
select * from tableName order by convert(columnName using gbk);
3,根据值进行排序
一次将字段值与"value1","value2","value3"进行比较,并按照对应的顺序进行输出,如果遇到str为null或者不存在的情况,则序列为0。
例:select * from tableName order by field(columnName,"value1","value2","value3");
边栏推荐
- Canvas text JS special effect composed of many circles
- 神经网络学习(1)前言介绍
- The simplest sklearn environment configuration tutorial in the whole network (100% success)
- mysql中的数据结果排名
- nacos2.1.0集群搭建
- 『怎么用』观察者模式
- LabVIEW experiment - temperature detection system (experimental learning version)
- 实现简单的RESTful API服务器
- 2022-7-14 JMeter simulates the login of different users for pressure test
- 28.插槽
猜你喜欢
![[BUUCTF-n1book][第二章 web进阶]SSRF Training](/img/29/8894d04b27e0e73c4458c27bd9b935.png)
[BUUCTF-n1book][第二章 web进阶]SSRF Training

Sort out Huawei ap-3010dn_ V2 configuration create WiFi

Unity ugui interaction (new ideas)

SQL injection

Comparison between symmetric encryption and asymmetric encryption

分布式一致性协议之Raft
![[deep learning] overview | the latest progress of deep learning](/img/b9/6117862397dcda4d555c819e913c9b.png)
[deep learning] overview | the latest progress of deep learning

Sticky.js page scrolling div fixed position plug-in

整理 华为AP-3010DN_V2配置创建wifi

这家十年内容产业基建公司,竟是隐形的Web3先行者
随机推荐
Sort out Huawei ap-3010dn_ V2 configuration create WiFi
redis操作利用游标代替keys
How to realize the drop-down option box of wechat applet
[NPM] the "NPM" item cannot be recognized as the name of cmdlets, functions, script files or runnable programs. Please check the spelling of the name. If the path is included, make sure the path is co
Probe into Druid query timeout configuration → who is the querytimeout of datasource and jdbctemplate effective?
Rich text style word image processing
Network principle (2) -- network development
JS touch screen game source code ice and snow journey
sticksy.js页面滚动div固定位置插件
Kubedm introduction
360 degree drag panorama plug-in tpanorama.js
NFT guide for musicians
[stl]stack & queue simulation implementation
mysql中的数据结果排名
Oracle10g单实例数据库升级到哪个版本好,求建议
What is steel grating?
Algorithm --- flip digit (kotlin)
(self drawn ugly picture) simple understanding tcp/ip three handshakes and four waves
OpenCV实现简单的人脸追踪
Guangzhou has carried out in-depth "100 day action" to check the safety of self built commercial houses, and more than 2 million houses have been checked in two months