MySQL Orderby a number, Nulls last

前端 未结 12 2520
再見小時候
再見小時候 2020-11-22 16:57

Currently I am doing a very basic OrderBy in my statement.

SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC

The probl

12条回答
  •  隐瞒了意图╮
    2020-11-22 17:45

    Why don't you order by NULLS LAST?

    SELECT * 
    FROM tablename
    WHERE visible = 1 
    ORDER BY position ASC NULLS LAST, id DESC 
    

提交回复
热议问题