Mysql之 order by 排序

num 为varchar 类型,按num 进行排序

select * from contest_info order by num asc

 

 得到结果是按字典序排序,并不是预期中以数字大小排序。

若想让数字格式的字符串按数字大小排序,则SQL修改为:

select * from contest_info order by num+0 asc

此时结果为:

 

 与预期结果一致

 

posted @ 2020-02-24 23:09  加油鸭Starry  阅读(369)  评论(0编辑  收藏  举报