I have the following query
SELECT * FROM table WHERE id IN (5,4,3,1,6)
and i want to retrieve the elements in the order specified in the "id in.." meaning it should return:
5 .... 4 .... 3 .... 1 .... 6 ....
Any ideas how to do that?
Use FIELD():
SELECT * FROM table WHERE id IN (5,4,3,1,6) ORDER BY FIELD(id, 5,4,3,1,6);
1.4m articles
1.4m replys
5 comments
57.0k users