比如数据库A,里面表a
    数据库B,里面表b
数据库A的表a里面有一并部分name跟表b一样那么怎样去插入那些name不一样的数据高手帮帮忙

解决方案 »

  1.   

    insert into a.a
    select * from b.b as t2  
    where not exists(select 1 from a.a as t1 where t1.name=t2.name)
      

  2.   

    insert into db2.table2(col1,col2) 
    select fl03,fd09 from db1.table1 
    where (fl03,fd09) not in (select col1,col2 from  db2.table)
      

  3.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
      

  4.   

    insert into a values (select * from test.b where test.name not in(select name from a))
      

  5.   

    如果不同数据库
    表a的name列跟表b的username列相同,名字全部对应
        表a的birth列一部分为空,空的在表b找得到,想把表b的birth列导入到表a中
    怎样写?
      

  6.   

    update a set birth = (select birth from db.b where db.b.username=a.name)
      

  7.   

    额,我自己搞出来了
    update  a.a as t1 set
    t1.sex=(select t2.sex from b.c as t2 where t1.name=t2.name)