首页 > 代码库 > sql 两张表关联修改数据

sql 两张表关联修改数据

Hr_DepartPlanWeek 部门周计划表:DepartMent部门名称,DepartMentID部门ID。

g_group部门表:gname部门名称,gid部门id

根据DepartMentID管理g_group表修改DepartMent

update Hr_DepartPlanWeek set DepartMent=t.gname 
from (select gname,gid from g_group left join Hr_DepartPlanWeek on g_group.GId=Hr_DepartPlanWeek.DepartMentID
)t
where t.GId=Hr_DepartPlanWeek.DepartMentID



sql 两张表关联修改数据