当前位置:网站首页>MySQL is sorted alphabetically
MySQL is sorted alphabetically
2022-07-06 06:22:00 【Do not let it rot】
Today's test raised a requirement , Sort by the first letter of the field
Because the general database code is utf-8 , His sorting method is to sort according to the English alphabet "a,b,c… "
It can be seen from the above table that , As long as we convert the fields to be sorted into GBK Code and then sort , You can sort by field initials , How can I convert the code into GBK Well ? stay MySQL Functions are provided in CONVERT() , This function can be used to get the value of a type
The usage of this function is CONVERT( Field USING GBK)
for example :
SELECT * FROM table ORDER BY CONVERT(field USING GBK) ASC
The following is my sql Example , My requirements are sorted by the initials of the units
Before no sorting
select
ier.id,
eor.id cid,
eor.sort,
ier.title,
ier.summary,
ier.expert_desc,
ier.proposal,
eor.status,
ier.tenant_id,
eor.level_one_code,
eor.cycle_id,
eor.monitor_organ_id,
eor.project_id,
so.name monitorOrganName
from
index_expert_reviews ier
left join
expert_organ_relation eor
on eor.expert_id=ier.id
and eor.tenant_id = ier.tenant_id
left join
sys_organ so
on so.id=eor.monitor_organ_id
and so.tenant_id = ier.tenant_id
LIMIT 0,
10
After ordering
select
ier.id,
eor.id cid,
eor.sort,
ier.title,
ier.summary,
ier.expert_desc,
ier.proposal,
eor.status,
ier.tenant_id,
eor.level_one_code,
eor.cycle_id,
eor.monitor_organ_id,
eor.project_id,
so.name monitorOrganName
from
index_expert_reviews ier
left join
expert_organ_relation eor
on eor.expert_id=ier.id
and eor.tenant_id = ier.tenant_id
left join
sys_organ so
on so.id=eor.monitor_organ_id
and so.tenant_id = ier.tenant_id
order by
CONVERT( monitorOrganName USING GBK) ASC LIMIT 0,
10
You can find that the virtual is at the bottom
边栏推荐
- LeetCode 731. 我的日程安排表 II
- 【Postman】Collections-运行配置之导入数据文件
- RestTemplate、Feign实现Token传递
- Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
- Resttemplate and feign realize token transmission
- PHP uses redis to implement distributed locks
- B - The Suspects
- Postman core function analysis - parameterization and test report
- Construction and integration of Zipkin and sleuth for call chain monitoring
- Isam2 and incrementalfixedlagsmooth instructions in gtsam
猜你喜欢
Left matching principle of joint index
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
[postman] collections - run the imported data file of the configuration
D - How Many Answers Are Wrong
F - true liars (category and search set +dp)
Data type of MySQL
Customize the gateway filter factory on the specified route
Play video with Tencent video plug-in in uni app
Technology sharing | common interface protocol analysis
全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
随机推荐
【无App Push 通用测试方案
JWT-JSON WEB TOKEN
Redis 核心技术与实战之 基本架构:一个键值数据库包含什么?
Simulation volume leetcode [general] 1062 Longest repeating substring
Delete the variables added to watch1 in keil MDK
Fault, error, failure of functional safety
Win10 cannot operate (delete, cut) files
在uni-app中使用腾讯视频插件播放视频
Manhattan distance sum - print diamond
Isam2 operation process
ESP32 ESP-IDF看门狗TWDT
Idea new UI usage
模拟卷Leetcode【普通】1143. 最长公共子序列
G - Supermarket
D - How Many Answers Are Wrong
Data type of MySQL
这些年用Keil遇到的坑
MySQL之基础知识
把el-tree选中的数组转换为数组对象
Technology sharing | common interface protocol analysis