0
USE [ASPDryrun]
GO
UPDATE [dbo].[Users]
SET [ID] = [IU].[PersNo],
[CostCenter] = [CC].[CostCenterID],
[OrgUnit] = [OU].[OrgUnitID]
FROM [dbo].[Users],
[dbo].[Import_UserData] AS [IU],
[dbo].[CostCenters] AS [CC],
[dbo].[OrgUnits] AS [OU]
WHERE [CC].[ID] = [IU].[CostCtr]
AND [OU].[ID] = [IU].[OrgUnit]
AND [IU].[CorporateEmail] IN (SELECT [Email]
FROM [dbo].[Users])
GO
我想更新某些用戶在另一張表上的電子郵件時的信息。但是這個查詢更新所有用戶並且不知道什麼是錯誤的,你能幫助我嗎?謝謝當電子郵件在另一個表上時如何更新表格?
您沒有加入任何有關的'dbo.Users'表查詢中的其他表的條件。 – 2011-03-01 16:47:09
也許我應該加上這個條件:'AND [IU]。[CorporateEmail] = [dbo]。[Users]。[Email]' Email是唯一的比較字段 – Vicent 2011-03-01 16:52:46