解决方案 »

  1.   

     select * from A where flag=1and id in('1','2')
    union
    select * from A where flag=2 and id in('1','2');
      

  2.   

    你这不就是个union all 么
      

  3.   

     select * from A where flag=1and id in('1','2')
    union
    select * from A where flag=2 and id in('1','2');最终要查出一条记录,您这个结果肯定是两条
      

  4.   

     select * from A where flag=1and id in('1','2')
    union
    select * from A where flag=2 and id in('1','2');最终要查出一条记录,您这个结果肯定是两条
    那就是我理解错了你的问题了,其实你不妨可以简单的例举点数据和你想要的结果,这样更直观
      

  5.   

     select * from A where flag=1and id in('1','2')
    union
    select * from A where flag=2 and id in('1','2');最终要查出一条记录,您这个结果肯定是两条
    那就是我理解错了你的问题了,其实你不妨可以简单的例举点数据和你想要的结果,这样更直观最后找到一种方法,是full join ,因为没有关联关系,所以用rownum做关联,大概就是 select rownum rn,* from A where flag=1and id in({list}) a
    union
    select rownum rn,* from A where flag=2 and id in({list}) b  on a.rn=b.rn
      

  6.   

     select * from A where flag=1and id in('1','2')
    union
    select * from A where flag=2 and id in('1','2');最终要查出一条记录,您这个结果肯定是两条
    那就是我理解错了你的问题了,其实你不妨可以简单的例举点数据和你想要的结果,这样更直观最后找到一种方法,是full join ,因为没有关联关系,所以用rownum做关联,大概就是 select rownum rn,* from A where flag=1and id in({list}) a
    union
    select rownum rn,* from A where flag=2 and id in({list}) b  on a.rn=b.rnselect rownum rn,* from A where flag=1and id in({list}) a full join
     select rownum rn,* from A where flag=2 and id in({list}) b  on a.rn=b.rn