更新 将B表的数据更新到A表中的某个字段的sql(根据条件)

时间:2021-08-27 19:15:00

update  A set FResponPositionID=(select FResponPositionID from B where A.funitid=B.fid 

 and B.fisleaf=1 and B.FIsOUSealUp=0 and   B.FResponPositionID <>A.FResponPositionID);


实际过程中:

将T_ORG_OUPartAdmin表中的FResponPositionID更新为对应的t_org_admin 中的FResponPositionID,具体如下:

update  T_ORG_OUPartAdmin set FResponPositionID=(select FResponPositionID from t_org_admin where T_ORG_OUPartAdmin.funitid=t_org_admin.fid 
 and t_org_admin.fisleaf=1 and t_org_admin.FIsOUSealUp=0 and   t_org_admin.FResponPositionID <>T_ORG_OUPartAdmin.FResponPositionID);