SELECT * FROM $t[table] ORDER BY rank ASC I want it to return info in ascending order (starting from smallest 'rank'), but leave the ones with 0 'rank' value to the end. Would that be possible? 0 0 1 0 3 6 should come in this order 1 3 6 0 0 0 Can it be done? Right now, obviously, it takes the ones with 0 value first... I don't want to skip them, I just want to leave them to the end.
As a quick solution, following should work.. SELECT *, IF(rank = 0, 99999, rank) AS new_rank FROM $t[table] ORDER BY new_rank ASC I hope there can be a better solution for this..
For a moment I was wondering what went wrong in query that it did not work Anyways, happy that it is working now, however, is 0 default value for rank column? You can in that case keep it as MAX value, e.g. 9999 as default and you won't have to handle it separately in query. Just another way to handle it.