How to order entries by one column (let's say named column13
). First should be entries where column13
is "val", then "aaa", then "ccc". I can't use GROUP BY column13 ASC
or similar. Is it possible to do it without writing 3 queries?
Asked
Active
Viewed 69 times
0

good_evening
- 21,085
- 65
- 193
- 298
-
Would http://stackoverflow.com/questions/4327159/mysql-specify-arbitrary-order-by-id work? – Stephen Booher Oct 05 '12 at 21:55
1 Answers
5
Use the FIELD()
construct available in MySQL:
SELECT stuff
FROM table
WHERE condition
ORDER BY FIELD(column13, 'val', 'aaa', 'ccc')

Mihai Stancu
- 15,848
- 2
- 33
- 51
-
"It's not that I'm a good comedian, it's that some people are just so easily amused." - Ron White – Mihai Stancu Oct 05 '12 at 22:04