如果两个表的对应关系为1对1或多对1,则用如下语句:update tableA set tableA.aa=(select bb from tableB where dd=tableA.cc) from tableA where exists(select * from tableB where dd=tableA.cc)
因为是在SQLSERVER中可以执行所以直接 update tableA t set t.aa=(select tt.bb from tableB tt where tt.dd=t.cc) 就可以了
set
tableA.aa=(select bb from tableB where dd=tableA.cc)
from
tableA
where
exists(select * from tableB where dd=tableA.cc)
update tableA t
set
t.aa=(select tt.bb from tableB tt where tt.dd=t.cc)
就可以了