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

 排序字段为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

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