views:

25

answers:

2

Hello!

I have a table that I select data from with a column called parent that's of unsigned integer type.

It has numbers from 0 to 12.

I want to select * from table order by parent asc, but with one exception: place the 0 at the end of the select so it would be like 1,2,3,4,5,6,7,8,9,0.

Is this possible with a single select in MySQL please?

A: 
select * 
from table 
order by case when parent is 0 then 1 else 0 end, 
    parent asc
RedFilter
+1  A: 

I would do something like this:

select * 
from your_table 
order by (parent != 0) desc, parent asc; 
Ike Walker
`select * from your_table order by parent=0, parent;`
Notinlist
Thank you both.
Francisc