Reputation: 67
Can I perform a query to order by an INT in ASC order but put any records with 0 last?
e.g.
1, 2, 3, 4, 6, 100, 0
Rather than
0, 1, 2, 3, 4, 6, 100
Upvotes: 2
Views: 1119
Reputation: 56367
select * from table order by if(your_field=0,1,0),your_field
Upvotes: 1
Reputation: 2343
SELECT IF(row>0, row, 100000) as sort_row ...... ORDER BY sort_row ASC
OR use UNION
Upvotes: 0