A,B是结构一样的表,如果在A表No字段中的记录在B表中不存在,则把这条记录插入B表。
A:Name No Time ...
   aa   1  ...
   bb   2  ...
   cc   3  ...B: Name No Time ...
   aa   1  ...
   gg   4  ...
   ff   5  ...=>
B: Name No Time ...
   aa   1  ...
   bb   2  ...
   cc   3  ...
   gg   4  ...
   ff   5  ...
???

解决方案 »

  1.   

    insert into B select * from A where No not in(select No from B)
      

  2.   

    insert into b(name,no,time) select name,no,time from a,b where a.no<>b.no
      

  3.   

    insert into b select * from a where no not in (select no from b)
      

  4.   

    非常正确
    insert into B select * from A where No not in(select No from B)
      

  5.   

    insert into b(name,no,time) 
    (
     select a.name,a.no,a.time from a 
     minus
     select b.name,b.no,b.time from b
    )
    本人觉得用not in,在效率上有影响,速度不如minus快.
      

  6.   

    对,如果记录上万的话in的速度是非常慢的,建议:
    insert into b(name,no,time) select name,no,time from a,b where a.no<>b.no
      

  7.   

    insert into b select * from a where no not in (select no from b)
      

  8.   

    insert into B select * from A where No not in(select No from B)