insert into shipc select * from (select * from shipa  union select * from shipb ) t

解决方案 »

  1.   

    insert into shipa 
    select * from shipb 
    where member_id not in (select member_id from shipa) 
      

  2.   

    insert into shipa 
    select * from shipb 
    where member_id not in (select member_id from shipa) insert into shipb 
    select * from shipa 
    where member_id not in (select member_id from shipb)
      

  3.   

    感谢回复,使用insert into shipc select * from (select * from shipa  union select * from shipb ) t
    由于主键id冲突,报错如下
    duplicate entry '1' for key 'PRIMARY'
    是否考虑建表用复合主键??
    使用insert into shipa 
    select * from shipb 
    where member_id not in (select member_id from shipa) 
    主键重复,不报错,但只能合并主键不重复的数据,可将shipb中不同于shipa的主键id进行合并