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)) T
order by NewOrder