我有两张表Employees
EmpID | EmpName | EmpDob
和WareHouseEmployeers
WarehouseEmpID | position | province
我需要根据Employee
表的值更新WareHouseEmployers
表。如何根据仓库省份和位置更新员工表的详细信息?
我试过这个,但它不起作用:
UPDATE Employee
SET a.EmpName = 'Steven', a.EmpDob = '5-5-1990'
FROM Employee a, WareHouseEmployee b,
WHERE
a.EmpID = b.WareHouseEmpID
AND position = 'manager', province = 'central'
有人可以帮我在SQL Server中执行此操作吗?
答案 0 :(得分:1)
请使用此脚本
UPDATE a
SET a.EmpName = 'Steven' , a.EmpDob='5-5-1990'
FROM Employee a
INNER JOIN WareHouseEmployee b ON a.EmpID = b.WareHouseEmpID
AND position = 'manager'
AND province = 'central'