How to exclude some values in sorting with MySQL?
You could try something like:
ORDER BY IF(SORT=0, 999999999, SORT)
You can use the ORDER BY IF
statement:
SELECT *
FROM table
ORDER BY IF(SORT = 0, 999999999, SORT)
or you can use the UNION ALL
statement to achieve this:
(SELECT * FROM table WHERE sort > 0 ORDER BY sort)
UNION ALL
(SELECT * FROM table WHERE sort = 0)