当前位置:网站首页>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
边栏推荐
- Full link voltage measurement: building three models
- 技术分享 | 常见接口协议解析
- sourceInsight中文乱码
- [API interface tool] Introduction to postman interface
- 模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
- 还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
- Technology sharing | common interface protocol analysis
- 把el-tree选中的数组转换为数组对象
- Simulation volume leetcode [general] 1296 Divide an array into a set of consecutive numbers
- [C language] qsort function
猜你喜欢
把el-tree选中的数组转换为数组对象
【Postman】Monitors 监测API可定时周期运行
How to extract login cookies when JMeter performs interface testing
Isam2 operation process
mysql按照首字母排序
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
[postman] the monitors monitoring API can run periodically
自定义指定路由上的Gateway过滤器工厂
ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
Customize the gateway filter factory on the specified route
随机推荐
ESP32 ESP-IDF看门狗TWDT
[C language] string left rotation
Summary of anomaly detection methods
Online and offline problems
Isam2 and incrementalfixedlagsmooth instructions in gtsam
The whole process realizes the single sign on function and the solution of "canceltoken" of undefined when the request is canceled
10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
测试周期被压缩?教你9个方法去应对
leetcode 24. Exchange the nodes in the linked list in pairs
Postman core function analysis - parameterization and test report
Simulation volume leetcode [general] 1296 Divide an array into a set of consecutive numbers
MFC 动态创建的对话框及改变控件的大小和位置
Understanding of processes and threads
数据库隔离级别
Pat (Grade B) 2022 summer exam
Idea new UI usage
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
Isam2 operation process
Is the test cycle compressed? Teach you 9 ways to deal with it
Database isolation level