這是正確的方式做到這一點更新,是這樣說的:與SQL更新加入
UPDATE [log].codesEntered
SET [log].codesEntered.countrycode =
(SELECT [user].[profile].countryCode
FROM [user].[profile]
INNER JOIN [log].codesEntered
ON [log].codesEntered.userid = [user].[profile].userid
WHERE [log].codesEntered.countryCode <> [user].[profile].countryCode
AND [log].codesEntered.campid = @campid
AND [log].codesEntered.portalid = @portalid
AND [user].[profile].countryCode <> ''
AND [user].[profile].countryCode <> '--')
或者這樣說:
UPDATE [log].codesEntered
SET [log].codesEntered.countrycode = [user].[profile].countryCode
FROM [log].codesEntered
INNER JOIN [user].[profile]
ON [log].codesEntered.userid = [user].[profile].userid
WHERE [log].codesEntered.countryCode <> [user].[profile].countryCode
AND [log].codesEntered.campid = @campid
AND [log].codesEntered.portalid = @portalid
AND [user].[profile].countryCode <> ''
AND [user].[profile].countryCode <> '--'
我正在使用SQL Server – user517406
第二個選項在語法方面看起來很標準 - [MSDN](http://msdn.microsoft.com/en-us/library/ms177523.aspx) – whytheq
嘗試訪問[此鏈接] (http://praveenbattula.blogspot.com/2009/05/how-to-write-inner-join-in-update-query.html)的語法和示例 –