select * from users order by injoin_time desc
如果injoin_time有为null的记录,为null的会排在最前面
解决方法:select * from users where injoin_time is not NULL order by injoin_time desc
如果injoin_time有为null的记录,为null的会排在最前面
解决方法:select * from users where injoin_time is not NULL order by injoin_time desc
本文介绍了一种SQL查询技巧,当需要按某个字段降序排列时,若该字段存在NULL值会导致NULL值的记录被排在最前面的问题。文章提供了解决方案,即通过添加一个WHERE子句来排除NULL值,确保数据能按预期正确排序。

1431

被折叠的 条评论
为什么被折叠?



