码迷,mamicode.com
首页 > 数据库 > 详细

mysql排序字段为空的排在最后面

时间:2019-08-08 19:38:31      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:pre   需要   sdn   排序   style   null   art   esc   rom   

 排序字段为orderid;

1、使用order by orderid desc实现降序时,orderid 为null数据的会排在数据的最后面;

但是,order by orderid升序时,orderid 为null的数据则会排在最前面,如果想要将orderid

为null的数据排在最后,就需要加上is null。

 

select * from user u order by u.orderid is null, u.orderid

 



原文链接:https://blog.csdn.net/w592376568/article/details/79217351

mysql排序字段为空的排在最后面

标签:pre   需要   sdn   排序   style   null   art   esc   rom   

原文地址:https://www.cnblogs.com/lxwphp/p/11322910.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!