2016-01-24 74 views
0

我有以下更新表基於標準的連接表

客戶1-多CustomerAddresses

客戶1-多CustomerCalls

我想基於在一列中的值更新CustomerAddresses CustomerCalls。像下面這樣:

Update CustomerAddresses 
Set CustomerAddresses.PostCode = 'xxx' 
Where CustomerCalls.CallType = 'x' 
+0

你的問題是什麼?你需要使用'UPDATE FROM'嗎?創建'JOIN' –

回答

1

您可以在更新語句中使用from條款,讓您也可以使用連接。像這樣的東西應該做的伎倆(雖然我不得不猜測列名...)

UPDATE CustomerAddresses 
SET CustomerAddresses.PostCode = 'xxx' 
FROM CustomerAddresses 
INNER JOIN Customers ON Customers.Address = CustomerAddresses.AddressId 
INNER JOIN CustomerCalls ON Customers.Calls = CustomerCalls.CallId 
WHERE CustomerCalls.CallType = 'x' 
+0

啊,這就是謝謝 – wingyip

+0

很高興幫助:-) –