A,B表结构完全相同,ID为自增关键字段,将B表的全部记录复制到A表,如果A表中有相同的记录则更新,没有相同的记录则添加此记录。
有什么方法实现以上功能?
ado+access
谢谢!

解决方案 »

  1.   

    insert into A
    select B.* from A,B where A.id <> B.id
      

  2.   

    A表B表在同一个数据库中吗,如是直接insert into A select * from B不就可以了!
      

  3.   

    重新生明一下刚才写的语句不对:以下的语句才是正确的.
    insert into A
    select b.* from b where b.id not in (select B.* from A,B where A.id =b.id)
      

  4.   

    我就是这样用的呀:
    WITH ADOQUERY DO
     BEGIN
     close;
     sql.Clear;
     sql.add('INSERT into LS SELECT * from TEMP');
     EXECSQL;
     end;
    end;
    问题是如果LS与TEMP有相同的记录时会出错,而我要求用TEMP中的记录更新LS中相同的记录。
      

  5.   

    insert into A
    select b.* from b where b.id not in (select B.id from A,B where A.id =b.id)
      

  6.   

    可以先把A的记录删除.然后再插入呀
    delete a from a,b where a.id=b.id
    insert into A
    select b.* from b where b.id  in (select B.id from A,B where A.id =b.id)