现有两句sql语句,
select b.t2 
from table1 a,table2 b
where a.t1 between b.t1 and b.t2;select a.t1 from table1 a
where not exists(
  select 1 from table2 b
  where a.t1 between b.t1 and b.t2);这2句如何合并成一句sql语句啊,请各位帮忙

解决方案 »

  1.   

    select b.t2  
    from table1 a,table2 b 
    where a.t1 between b.t1 and b.t2; 
    union
    select a.t1 from table1 a 
    where not exists( 
      select 1 from table2 b 
      where a.t1 between b.t1 and b.t2); 
      

  2.   

    谢谢回答,除union方式还有其他方式吗?
      

  3.   

    select a.t1,b.t2  
    from table1 a,table2 b 
      

  4.   

    怎么个合并成一句sql,你想要什么样的结果?
      

  5.   

    select nvl(b.t2,a.t1) as t
    from table1 a
    left outer join table2 b
    on a.t1 between b.t1 and b.t2