有一条sql
select * from table 
where id in (select id from table1) 
or id in (select id from table2)就是id 要在两个表里选,我怎么样要让table1的id 排在 table2的前面希望高手回答,谢谢了 !!!

解决方案 »

  1.   

    select * from table  
    where id in (select id from table1)  
    union 
    select * from table  
    where id in (select id from table2) 
      

  2.   

    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
      

  3.   

    谢谢了dobear_0922 和 Quixotenj 了问题解决了