读书人

select 的排序有关问题 高手们快来啊

发布时间: 2012-02-08 19:52:21 作者: rapoo

select 的排序问题 高手们快来啊,谢谢了·······················
有一条sql
select * from table
where id in (select id from table1)
or id in (select id from table2)

就是id 要在两个表里选,我怎么样要让table1的id 排在 table2的前面

希望高手回答,谢谢了 !!!

[解决办法]
用 union 呢
[解决办法]

SQL code
select * from (select *, NewOrder=1 from tb where id in (select id from table1) union all select *, NewOrder=2 from tb where id in (select id from table2) and id not in (select id from table1)) Torder by NewOrder 

读书人网 >SQL Server

热点推荐