MySQL Orderby a number, Nulls last

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

    Something like

    SELECT * FROM tablename where visible=1 ORDER BY COALESCE(position, 999999999) ASC, id DESC
    

    Replace 999999999 with what ever the max value for the field is

提交回复
热议问题