按顺序显示值 [英] display values in order
本文介绍了按顺序显示值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询
i have a query
"select * from details where id=7 or id=3 or id=11 or id=9"
在执行此查询时,我需要这样的结果集.
while executing this query i need a result set like this.
Id Name<br />
<br />
7 Ammu<br />
3 Jithu<br />
11 yana<br />
9 Achu<br />
How is it possible.? Can anyone help me?
推荐答案
尝试一下.
Try this.
select * from details where id IN (7, 3, 1) order by id desc
或
or
select * from details where id=7 or id=3 or id=1 order by id desc
我得到了解决方案.解决方案是
i got the solution.. solution is
"select * from details where id=7 union all select * from details where id=3 union all select * from details where id=11 union all select * from details where id=9"
这篇关于按顺序显示值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文