大家好,又见面了,我是你们的朋友全栈君。
针对字符串类型的字符排序 需要先转换成数字再进行排序
1.直接用加法
字符串+0
select * from orders order by (mark+0) desc
2.使用函数
CAST(value as type); CONVERT(value, type);
注: 这里的type可以为: 浮点数 : DECIMAL 整数 : SIGNED 无符号整数 : UNSIGNED
select * from orders order by CONVERT(mark,SIGNED) desc
select * from orders order by CAST(mark as SIGNED) desc
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/141712.html原文链接:https://javaforall.cn
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有