检索 id = 2 or id = 5 or id = 9 or id = 56 or id = 38.
然后按照 2 , 5, 9, 56, 38 这个顺序排列,这是题目要求
 
以下为解决方案:
1.SELECT * FROM `test` WHERE `id` IN(2,5,9,56,38) ORDER BY FIELD(`id`,2,5,9,56,38); (方案出自:http://www.phptext.net/article_view.php?id=199)
2.select * case `id` when 38 then 57 else `id` end as myorder from test where find_in_set(`id`,2,5,9,56,38) order by myorder
3.(此种不是很明白)
(SELECT * FROM `account_biz` where  id = 2)
UNION (select * from account_biz where   id = 5)
UNION (select * from account_biz where   id = 9)
UNION (SELECT * FROM `account_biz` where  id = 56)
UNION (select * from account_biz where   id = 38);
 
 
 
posted on 2015-02-10 18:32  幸福之家128817  阅读(1564)  评论(0编辑  收藏  举报