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

  • Post author:
  • Post category:其他


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);

上述SQL会执行全部,再次实现的sql如下:

select a.fresponpositionid name, b.fresponpositionid as newname

from T_ORG_OUPartAdmin a, t_org_admin b where a.funitid=b.fid   and ((a.FResponPositionID  <> b.FResponPositionID)

or (b.FResponP



版权声明:本文为douml88原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。