A和B表中有共同的字段tempid
怎么将A表中B中没有的tempid的数据插入到B表
且对已插入的数据不能再次插入
求!!!

解决方案 »

  1.   

    insert b
    select c.* from a, b c--c是别名
    where a.tempid <> c.tempid
      

  2.   

    insert b(tmpid)
    select a.tmpid from a
    where a.tempid not in (selec tempid from b)
      

  3.   

    into?
    //---------------------------//
    不行
      

  4.   

    insert into t1
    select id,name from t2
    where id not in (select t1.id from t1,t2 where t1.id=t2.id)
      

  5.   

    A,B有不同类型的字段吗
    name 随便替换一个值。
      

  6.   

    insert b(tmpid)
    select a.tmpid from a
    where a.tempid not in (selec tempid from b)
      

  7.   

    not in (selec tempid from b) 可以,但速度很慢,