mysql SQL: specific item to be first and then to sort the rest of the items

select id,name 
from friends 
order by id=5 desc

(given you don’t care about order of the rest, otherwise, e.g. rest by id asc)

select id,name 
from friends 
order by id=5 desc, id asc

Leave a Comment