mysql 排序使null值排在最後

我們在使用排序 order by 的時候,如果使asc排序,發現null值的數據總會排在最前面。

解決辦法:使用 is null,在需要null值排在後面的字段前加上"該字段名  is null,"

例如: order by sort asc    改寫成 order by sort is null, sort asc 

order by name asc, sort asc 改寫成   order by name asc, sort is null, sort asc

oracle https://www.cnblogs.com/anlove0328-1121/p/5481383.html

參考:https://blog.csdn.net/layman1024/article/details/79257756

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章