把tb2的数据插入tb1
注:要批量的,tb1本来就有数据
表结构如下tb1fhh     
203271 
tb2
jwsx#
203187  想的结果tb1fhh     
203271
203187  

解决方案 »

  1.   

    insert into tb1
     select * from tb2
      

  2.   

    如果是有多列的话,就指定列insert into tb1(fhh)
    select jwsx# from tb2
      

  3.   

    --将tb2中不包含在tb1中的数据插入tb1
    create table tb1
    (fhh varchar(100))create table tb2
    (jwsx# varchar(100))insert into tb1 select '203271'
    insert into tb2 select '203187'insert into tb1
    select * from tb2 t1 where not exists(select 1 from tb1 where fhh=t1.jwsx#)
      

  4.   

    insert into tb1 select * from tb2 t where not exists(select 1 from tb1 where fhh=t.jwsx#)
      

  5.   

    insert into tb1 
    select * from tb2 t where not exists(select 1 from tb1 where fhh=t.jwsx#)