你见过ORDER BY -title DESC这种用法吗?

在查看网站SQL语句时,发现这样一样语句,ORDER BY -title DESC。
第一反应是不是写错了,-title DESC不是应该和title ASC一样吗?

检测了下,两者结果是不一样的。

假定title有:旅游1线,20路,112路,113路

title ASC,是 112路,113路,20路,旅游1线
-title DESC,是 旅游1线,20路,112路,113路
-title ASC,是 113路,112路,20路,旅游1线
title DESC,是 旅游1线,20路,113路,112路

其中-title DESC,是 旅游1线,20路,112路,113路,20路在112路前面。

那么为什么会这样呢?
SELECT title,-title FROM hx_bus WHERE ...
查看到:
title -title   --title
112路 -112   112
113路 -113   113
20路 -20       20
旅游1线 -0    0


原来加了-(负号)后,中文的title转变成数字了,无法转变的就变成了0。
这样ORDER BY -title DESC时,按照数字排序,20路才能排在112路前面,同时112路在113路前。

所以,在某些情况下,还是需要用到ORDER BY -title DESC这种用法的。
13:05:53.462 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList_COUNT - [debug,135] - ==> Preparing: SELECT count(0) FROM rf_sales_application 13:05:53.463 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList_COUNT - [debug,135] - ==> Parameters: 13:05:53.464 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList_COUNT - [debug,135] - <== Total: 1 13:05:53.464 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList - [debug,135] - ==> Preparing: select id, user_id, user_name, applicant, department, process_number, title, project_name, project_no, project_level, initial_contact, contact_info, sales_leader, change_sales_leader, client_company_name, change_customer_name, project_analysis, remark, create_by, create_time, update_by, update_time from rf_sales_application LIMIT ? 13:05:53.465 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList - [debug,135] - ==> Parameters: 10(Integer) 13:05:53.466 [http-nio-7002-exec-26] DEBUG c.r.b.m.R.selectRfSalesApplicationList - [debug,135] - <== Total: 2 13:06:10.479 [http-nio-7002-exec-69] DEBUG c.r.b.m.R.insertRfSchemeReviewQuote - [debug,135] - ==> Preparing: insert into rf_scheme_review_quote ( user_id, user_name, title, project_name, project_no, sales_leader, client_company_name, initial_contact, contact_info, project_level, review_quote_amount, quote_no, quote_date, quote_version, quote_diff_desc, note_desc, create_time ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate(), ?, ?, ?, ? ) 13:06:10.479 [http-nio-7002-exec-28] INFO o.o.e.c.a.DoButtonOperationAspect - [around,43] - params:{"formCode":"FAPSBJ_WMA","isLowCodeFlow":false,"lfFields":{"userId":1,"userName":"超级管理员","title":"超级管理员-方案评审报价-2025-09-16","salesLeader":"傅涵东","projectNo":"RF2025-086","projectName":"无锡小天鹅拓展线25-01","projectLevel":"老客户","initialContact":"张方绪","contactInfo":"18511751822","clientCompanyName":"北京起重运输机械设计研究院有限公司","reviewQuoteAmount":"1111","quoteNo":"11111","quoteVersion":"11111","quoteDiffDesc":"1111","noteDesc":"111111"},"operationType":1,"userId":"1"},formCode:FAPSBJ_WMA 13:06:10.481 [http-nio-7002-exec-69] DEBUG c.r.b.m.R.insertRfSchemeReviewQuote - [debug,135] - ==> Parameters: 1(Long), 超级管理员(String), 超级管理员-方案评审报价-2025-09-16(String), 无锡小天鹅拓展线25-01(String), RF2025-086(String), 傅涵东(String), 北京起重运输机械设计研究院有限公司(String), 张方绪(String), 18511751822(String), 老客户(String), 1111(String), 11111(String), 11111(String), 1111(String), 111111(String), 2025-09-16 13:06:10.478(Timestamp) 13:06:10.483 [http-nio-7002-exec-69] DEBUG c.r.b.m.R.insertRfSchemeReviewQuote - [debug,135] - <== Updates: 1 13:06:10.484 [http-nio-7002-exec-28] INFO o.o.e.b.a.p.SubmitProcessImpl - [doProcessButton,49] - Start submit process. param:DIVRfSchemeReviewQuoteVo(userId=1, userName=null, applicant=null, department=null, processNumber=null, title=null, projectName=null, projectNo=null, salesLeader=null, clientCompanyName=null, initialContact=null, contactInfo=null, projectLevel=null, reviewQuoteAmount=null, quoteNo=null, quoteDate=null, quoteVersion=null, quoteDiffDesc=null, noteDesc=null, fileUpload=null, remark=null, createBy=null, createTime=null, updateBy=null, updateTime=null) 13:06:10.485 [http-nio-7002-exec-28] DEBUG c.r.b.d.m.D.insert - [debug,135] - ==> Preparing: INSERT INTO rf_scheme_review_quote ( user_Id, user_name, create_time ) VALUES ( ?, ?, ? ) 13:06:10.486 [http-nio-7002-exec-28] DEBUG c.r.b.d.m.D.insert - [debug,135] - ==> Parameters: 1(Integer), 超级管理员(String), 2025-09-16 13:06:10.485(Timestamp) 13:06:10.488 [http-nio-7002-exec-28] DEBUG c.r.b.d.m.D.insert - [debug,135] - <== Updates: 1 13:06:10.500 [schedule-pool-9] DEBUG c.r.s.m.S.insertOperlog - [debug,135] - ==> Preparing: insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate()) 13:06:10.500 [schedule-pool-9] DEBUG c.r.s.m.S.insertOperlog - [debug,135] - ==> Parameters: 方案评审报价ttt(String), 1(Integer), com.ruoyi.web.controller.bpm.RfSchemeReviewQuoteController.add()(String), POST(String), 1(Integer), admin(String), 睿丰自动化(String), /bpm/scheme_review_quote(String), 127.0.0.1(String), 内网IP(String), {"clientCompanyName":"北京起重运输机械设计研究院有限公司","contactInfo":"18511751822","createTime":"2025-09-16 13:06:10","id":52,"initialContact":"张方绪","noteDesc":"111111","params":{},"projectLevel":"老客户","projectName":"无锡小天鹅拓展线25-01","projectNo":"RF2025-086","quoteDiffDesc":"1111","quoteNo":"11111","quoteVersion":"11111","reviewQuoteAmount":"1111","salesLeader":"傅涵东","title":"超级管理员-方案评审报价-2025-09-16","userId":1,"userName":"超级管理员"}(String), {"msg":"操作成功","code":200}(String), 0(Integer), null, 7(Long) 13:06:10.505 [schedule-pool-9] DEBUG c.r.s.m.S.insertOperlog - [debug,135] - <== Updates: 1 13:06:10.527 [http-nio-7002-exec-28] INFO o.a.e.i.b.d.BpmnDeployer - [deploy,105] - Processing resource FAPSBJ_WMA_53.bpmn AAP 13:06:10.683 [jimu-Async-Executor-2] INFO o.o.e.b.s.b.ActivitiBpmMsgTemplateServiceImpl - [getContent,535] - content数据转换,activitiBpmMsgVo:{"appPushUrl":"","bpmnCode":"FAPSBJ","emailUrl":"/user/workflow/Upcoming/check/FAPSBJ_WMA/FAPSBJ/FAPSBJ_WMA_53","formCode":"FAPSBJ_WMA","processId":"FAPSBJ_WMA_53","processName":"方案评审报价","processType":"","taskId":"dc50a3c9-92ba-11f0-b04a-0045e2cb0847","url":"/user/workflow/Upcoming/check/FAPSBJ_WMA/FAPSBJ/FAPSBJ_WMA_53","userId":"101"},msgNoticeType:1 13:06:10.685 [jimu-Async-Executor-2] INFO o.o.e.b.s.b.ActivitiBpmMsgTemplateServiceImpl - [getContent,548] - 转换后数据content:您有1个方案评审报价FAPSBJ_WMA_53需要处理 13:06:10.686 [jimu-Async-Executor-2] ERROR o.o.e.b.s.b.ActivitiBpmMsgTemplateServiceImpl - [getEmployee,511] - 流程消息查询员工信息失败,消息入参{"appPushUrl":"","bpmnCode":"FAPSBJ","emailUrl":"/user/workflow/Upcoming/check/FAPSBJ_WMA/FAPSBJ/FAPSBJ_WMA_53","formCode":"FAPSBJ_WMA","processId":"FAPSBJ_WMA_53","processName":"方案评审报价","processType":"","taskId":"dc50a3c9-92ba-11f0-b04a-0045e2cb0847","url":"/user/workflow/Upcoming/check/FAPSBJ_WMA/FAPSBJ/FAPSBJ_WMA_53","userId":"101"} 13:06:11.457 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList_COUNT - [debug,135] - ==> Preparing: SELECT count(0) FROM rf_scheme_review_quote 13:06:11.457 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList_COUNT - [debug,135] - ==> Parameters: 13:06:11.457 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList_COUNT - [debug,135] - <== Total: 1 13:06:11.457 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList - [debug,135] - ==> Preparing: select id, user_id, user_name, applicant, department, process_number, title, project_name, project_no, sales_leader, client_company_name, initial_contact, contact_info, project_level, review_quote_amount, quote_no, quote_date, quote_version, quote_diff_desc, note_desc, file_upload, remark, create_by, create_time, update_by, update_time from rf_scheme_review_quote LIMIT ? 13:06:11.457 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList - [debug,135] - ==> Parameters: 10(Integer) 13:06:11.462 [http-nio-7002-exec-13] DEBUG c.r.b.m.R.selectRfSchemeReviewQuoteList - [debug,135] - <== Total: 5 怎么解决新增操作会增加两条数据,一条正常,另一条为空的数据,需要流程插入正确的数据,不需要另一条数据插入
最新发布
09-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值