mysqlソート

536 ワード

SQLクエリ文は、select*from table where(ID=10)or(ID=32)or(ID=22)or(ID=76)or(ID=13)or(ID=44)結果を10,32,22,76,13,44の順で検索します.
select * from table where id in(10,32,22,76,13,44) order by field (id,10,32,22,76,13,44); 

 
(select * from table where ID = 10) union (select * from table where ID = 32) union (select * from table where ID = 22) union (select * from table where ID = 76) union (select * from table where ID = 13) union (select * from table where ID = 44)