What's the best way to sort results of a given query by fixed column values ?
- by eugene y
Example:
SELECT id, name FROM user WHERE id IN (1,2,3,4,5)
ORDER BY FIELD(id, 2, 3, 4, 1, 5)
I've seen some examples using FIND_IN_SET() or FIELD() functions. Which one is better? Are there any more efficient approaches?
Order is supposed to change rarely.