没有订购的清单 [英] List without ordering
本文介绍了没有订购的清单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
select * from tablename where id in(3,1,6,2);
我正在按升序获得结果.
我想按给定的顺序(为3,1,6,2).
I am getting the result in ascending order.
I want to get in the order I given.(as 3,1,6,2).
How can i do that?
推荐答案
如果这是您唯一可以订购的产品,那么您就必须非常不愉快:
If that is the only thing you can order by, then you have to be fairly unpleasant:
SELECT * FROM tablename WHERE id IN (3, 1, 6, 2) ORDER BY
(Case When id = 3 then 0
When id = 1 then 1
When id = 6 then 2
When id = 2 then 3
Else id End)
这篇关于没有订购的清单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文