sidewinder
sidewinder

Reputation: 3163

MySQL - Ordering all data in alphabetical order but placing a particular item last

Assuming I have the following, data from a field:

Category Name
-------------

Games
Movies
All
Music
Software

I want to order the above data in alphabetical (ascending) order but I want 'All' to appear last at the bottom of the list. Not sure how to do this. Thanks.

Upvotes: 1

Views: 2074

Answers (2)

HBublitz
HBublitz

Reputation: 680

SELECT Category_Name, if(Category_Name='All',1,0) as orderAid
FROM CategoryTable
ODER BY orderAid, Category_Name

Upvotes: 1

a1ex07
a1ex07

Reputation: 37354

ORDER BY category_name='All' ASC, category_name ASC

Upvotes: 7

Related Questions