+ -
当前位置:首页 → 问答吧 → 数据查询排序和结果合并问题

数据查询排序和结果合并问题

时间:2011-08-13

来源:互联网


id name num
1 aa 3
2 bb 0
3 cc 0
4 dd 1
5 ee 2
6 ff 5


查询条件 3,1,4

如 select id,name from 表 where id in(3,1,4)

如何排序才能使果结为下面这样
id name num
3 cc 0
1 aa 3
4 dd 1

如何将这个结果合并成 cc,aa,dd

作者: php600   发布时间: 2011-08-13

没办法
只能

select * from tb where id=3
union all
select * from tb where id=1
union all
select * from tb where id=4

作者: rucypli   发布时间: 2011-08-13