MySQL Orderby a number, Nulls last

前端 未结 12 2674
再見小時候
再見小時候 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:47

    This is working fine:

    SELECT * FROM tablename ORDER BY position = 0, position ASC;
    

    position
    1 
    2
    3
    0
    0
    

提交回复
热议问题