Ve skutečnosti je to lepší:
SELECT * FROM your_table
WHERE id IN (5,2,6,8,12,1)
ORDER BY FIELD(id,5,2,6,8,12,1);
zde je dokumentace FIELD:
http://dev.mysql.com/doc /refman/5.0/cs/string-functions.html#function_field
Ve skutečnosti je to lepší:
SELECT * FROM your_table
WHERE id IN (5,2,6,8,12,1)
ORDER BY FIELD(id,5,2,6,8,12,1);
zde je dokumentace FIELD:
http://dev.mysql.com/doc /refman/5.0/cs/string-functions.html#function_field