SELECT a.p,* FROM tb1 t,( SELECT 5 as id, 1 as p union SELECT 9 as id, 2 as p union SELECT 2 as id, 3 as p union SELECT 1 as id, 4 as p union SELECT 10 as id, 5 as p ) a where t.id=a.id order by a.p