HELP
HELP

Reputation: 14575

MySQL query question

I have a list of categories ordered alphabetically but I want to be able to specify a single category to be included last is it possible to do this with MySQL?

for example

current output:

a
b
c
d
e
f
g
h

desired output:

b
c
d
e
f
g
a

Current MySQL code.

 SELECT * FROM categories ORDER BY parent_id, category ASC

Upvotes: 1

Views: 40

Answers (1)

Mark Byers
Mark Byers

Reputation: 838036

You can use that 'a' = 'a' returns 1 and 'a' = 'b' returns 0:

SELECT * FROM categories ORDER BY parent_id, category = 'a', category

Upvotes: 2

Related Questions