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