SqL Server的Update: Update A Set A.字段1=B.字段1, A.字段2=B.字段2 From A, B Where A.ID=B.IDAccess: Update A, B Set A.字段1=B.字段1, A.字段2=B.字段2 Where A.ID=B.IDOracle: Update A Set (字段1,字段2) = (Select 字段1,字段2 from B Where B.ID=A.ID) ------------Insert Into ASelect B.*From B Left Join A On B.ID=A.IDWhere A.ID Is Null
{当A表的ID字段和B表的ID字段一样时,则用B表当前记录更新A表的相应记录当A表的ID字段和B表的ID字段不一样时,则把B表当前记录插入到A表}就两个动作delete from A where id in(select id from B); insert into A(.....) SELECT ... FROM B;
如果你是ORACLE数据库的话可以用函数merge函数merge into A表 A USEING B表 B on (A.ID=B.ID) when matched thenupdate set A.(字段)=B.(字段),...... when not matched theninsert (A表字段,。。。) values(B表字段。。。。)