有两张表,一张员工表名字为old是部门名称BMMC 部门代码BMDM(这个代码是老的)
另一张部门信息表new同样包含BMMC 和 BMDM(新的执行标准)两个字段.现在需要参照new来进行更新old.
代码如下
update old
set old.BMDM=new.BMDM
from old,new
where old.BMMC=new.BMMC
另一张部门信息表new同样包含BMMC 和 BMDM(新的执行标准)两个字段.现在需要参照new来进行更新old.
代码如下
update old
set old.BMDM=new.BMDM
from old,new
where old.BMMC=new.BMMC
set a.BMDM=(select max(b.BMDM)
from new b
where a.BMMC=b.BMMC)
BMMC应该是主key
加上max没有影响