如何在更新查询中联接两个表? [英] How to join two table in update query?
本文介绍了如何在更新查询中联接两个表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有sql查询...
请参阅表员工或部门.
员工表= {Empid,Mgrid,Name,Deptid}
餐桌部门= {Deptid,Hod,Location,Phone}
我想更新部门表.一个mgrid {somthing},它的某个雇员和每个雇员下都有一个部门id.每个员工部门的电话号码都将更新为新电话号码.
如何更新此表..
I have sql query…
See table employee or department.
table employee ={Empid,Mgrid,Name,Deptid}
table department = {Deptid,Hod,Location ,Phone}
I want to update department table. A mgrid{ somthing} whose under some employee and each employee have a department id . each employee department phone no to update with new phone no.
How to update this table..??
推荐答案
请在下面的查询中尝试
try below query
update department
set phone = YourValue
from department d
inner join employee AS e ON d.deptid = e.deptid
where YourCondition
UPDATE A
SET A.Phoneno= 'XXXXXX'
FROM Department A, Employee B
WHERE A.deptId=B.deptId
and B.EmpId = 'E001'
Update d
Set phone = @newphoneNo
From department d join Employee e
on d.deptid = e.deptid
where employeeid = @empid
这篇关于如何在更新查询中联接两个表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文