MySQL specifying exact order with WHERE `id` IN (...)
- by Gray Fox
Is there an easy way to order MySQL results respectively by WHERE id IN (...) clause?
Example:
SELECT * FROM articles WHERE articles.id IN (4, 2, 5, 9, 3)
to return
Article with id = 4
Article with id = 2
Article with id = 5
Article with id = 9
Article with id = 3
and also
SELECT * FROM articles WHERE articles.id IN (4, 2, 5, 9, 3) LIMIT 2,2
to return
Article with id = 5
Article with id = 9