有两个表,表结构都一样,我想把这两个表select *的结果集合并到一个结集中,请问如何写?

解决方案 »

  1.   

    select * from a
    union all
    select * from b
      

  2.   


    --不合并重复行
    select * from a
    union all
    select * from b
    --合并重复行
    select * from a
    union 
    select * from b
      

  3.   

    select * from a where id not in (select id from b)
    union
    select * from b
      

  4.   

    select * from a
    union 
    select * from b
      

  5.   

    多个表呢?是不是全部UNION ALL
      

  6.   

    select * from a
    union all
    select * from b
    union all
    select * from c
      

  7.   

    select * from a
    union all
    select * from b
      

  8.   

    select * from a
    union  --去重复记录
    select * from b
      

  9.   

    select * from tb
    union all
    select * from tb2orselect * from tb
    union
    select * from tb2
      

  10.   

    select * from tb
    union all  ---加ALL不去重复记录
    select * from tb2orselect * from tb
    union   ---------去除重复记录
    select * from tb2
    加多个表,在加UNION就行