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

2021-06-11  本文已影响0人  深渊凝视

排序字段为record_time ;

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

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

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

SELECT
*
FROM

rescue_progress_log a

WHERE a.rescue_id = xxxx

ORDER BY a.record_time is null, a.record_time ASC, a.create_time ASC
上一篇 下一篇

猜你喜欢

热点阅读