我的问题是:
我有2个表分配和服务 我试图从另一个表的列数据中更新一列。
UPDATE [Services]
SET
TeamID = (SELECT [AssignedTeam]
FROM [Assignment]
WHERE [ServiceName] in ([Services].[ServiceName]))
WHERE
EXISTS (
SELECT [ServiceName]
FROM [Assignment])
它不起作用。有人可以帮我解决这个问题吗? THX
答案 0 :(得分:3)
使用JOIN
更新。
<强>查询强>
UPDATE t1
SET t1.[TeamID] = t2.[AssignedTeam]
FROM [Services] t1
JOIN [Assignment] t2
ON t1.[ServiceName] = t2.[ServiceName];
答案 1 :(得分:1)
UPDATE [Services] SET TeamID = [AssignedTeam] FROM [Assignment] WHERE [Assignment].[ServiceName] = [Services].[ServiceName]