ORDER BY field(id, 9, 1, 4); http://dev.mysql.com/doc /refman/5.5/da/string-functions.html#function_field