请问表A 有 NAME AGE 
    表B 有 NAME AGE 字段 A,B表结构完全一样
如何把A,B表所有的记录合并到同样结构的表C中去,我刚学SQL,请前辈们帮忙给以个SQL语句,在线等,谢谢。

解决方案 »

  1.   

    insert C
    select * from a union all select * from b
      

  2.   


    --如果C存在
    insert into c
    select * from a
    union all
    select * from b--如果C不存在
    select * into c from
    (
    select * from a
    union all
    select * from b
    ) t
      

  3.   

    select * into C 
    from (select * from A union all select * from B) tinsert C
      select * from A union all select * from B二选一
      

  4.   

    谢谢,表C存在,UNION ALL是不排重吧!
      

  5.   

    insert C
      select * from A union all select * from B