sql 两张表关联修改数据
来源:程序员人生 发布时间:2014-11-24 08:12:46 阅读次数:3887次
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
生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠