请教:有2个表,表1和表2.想每天把表1的记录放到表2里,表2里已经有的记录即以前放过的记录就不再放了。就是说每天要把表1里新出现的表2里没有的记录进入表2,怎样实现呢??(不好意思,小弟表达能力有限)

解决方案 »

  1.   

    insert into 表2 
    select * from 表1
    where not exists(select * from 表2 where 表1.关键字= 表2.关键字)
      

  2.   

    insert into 表2 
    select * from 表1 
    where id not (select Id from 表2 )
      

  3.   

    insert into 表2 
    select * from 表1 
    where id not in (select Id from 表2 )
      

  4.   

    楼主如果是不管表1中修改和删除和记录的话是否是可以这样,在表1表2中都加一个时间,保存记录保存的时间,那么第二天表2从表1导数据的话就直接日期等于第二天就行了,要不然就insert into 表2 
    select * from 表1 
    where id not in (select Id from 表2 )这个行了