Hi All,
My query is: select name from customer where id (1, 5, 3, 2);
The result I am getting is descending order of id like this:
1 a
2 b
3 c
5 d
How can I get order by my specific values in id list like this:
1 a
5 d
3 c
2 b
Thanks!
Darma
IN clause value list-order by
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

VulpesRank #55 · 29.2K reputationPosted Aug 20, 2014, 12:25 AM EDT
Ankur JainRank #2,475 · 567 reputationPosted Aug 20, 2014, 12:19 AM EDT
try like this..
SELECT name FROM customer ORDER BY FIELD('id',1,5,3,2)
please mark it as answer if its helpful...
darma tejaRank #3,199 · 449 reputationPosted Aug 20, 2014, 12:52 AM EDT
@Ankur jain: It is giving me error at field (is field not may work for SQL 2005?)
VulpesRank #55 · 29.2K reputationPosted Aug 20, 2014, 1:01 AM EDT
It's a pity that it's not available in SQL Server as well.