|
有两程方法可以做到,一个是用比较查询找出两个表不匹配项目,再将不匹配项目新增到表一中,还有一种不用查询即用程序来达到的方法
dim cn as adodb.connection
dim rs1,rs2 as adodb.recordset
Set cn = New ADODB.Connection
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs2.Open "select * from 表二", cn, adOpenKeyset, adLockPessimistic
for i=1 to rs2.recordcount
rs1.Open "select * from 表一 where 字段A=' & rs2("字段A") & "'",cn,adOpenKeyset, adLockPessimistic
if rs1.recordcount=0 then
rs1.addnew
rs1("字段A")=rs2("字段A")
rs1("字段B")=rs2("字段C")
rs1.update
rs1.close
rs2.movenext
next
rs2.close |
|