Currently I am doing a very basic OrderBy in my statement.
SELECT * FROM tablename WHERE visible=1 ORDER BY position ASC, id DESC
The problem with this is that NULL entries for 'position' are treated as 0. Therefore all entries with position as NULL appear before those with 1,2,3,4. eg:
NULL, NULL, NULL, 1, 2, 3, 4
Is there a way to achieve the following ordering:
1, 2, 3, 4, NULL, NULL, NULL.
I found this to be a good solution for the most part:
Why don't you order by NULLS LAST?
For a
DATE
column you can use:NULLS last:
Blanks last:
Something like
Replace 999999999 with what ever the max value for the field is
Try using this query: