我有兩個表具有相同的模式,一個只是一個表,數據被批量加載到另一個是我的活表。我想從上傳表格中更新行數不同的活動表格。我認爲我在這裏非常接近,但我的更新會在哪裏發揮作用?更新錶行的列值不同於另一個表
這給了我更新的行實際上有變化我要推到我的直播表:
SELECT USC.* FROM UpdateStagingCustomers AS USC
JOIN StagingCustomers AS SC
ON USC.CustomerNumber = SC.CustomerNumber
AND USC.ManufacturerID = SC.ManufacturerID
WHERE USC.ManufacturerID=18 AND SC.ManufacturerID = 18
AND USC.CustomerNumber IN(
SELECT CustomerNumber FROM StagingCustomers WHERE ManufacturerID=18
)
AND
(
USC.Address1 <> SC.Address1 OR
USC.Address2 <> SC.Address2 OR
USC.AuthorizedDealer <> SC.AuthorizedDealer OR
USC.City <> SC.City
)
'WHERE USC.ManufacturerID = 18 AND SC.ManufacturerID = 18 AND USC.CustomerNumber IN(SELECT FROM CUSTOMERNUMBER WHERE StagingCustomers ManufacturerID = 18 )' 這是否產生不同的結果不僅僅是USC.ManufacturerID = 18?您正在加入CustomerNumber和ManufacturerID,因此它似乎是多餘的。更多你的問題,你試圖更新哪個表? – cadrell0
補充說,作爲一個安全的警衛,我猜可能不需要。我試圖用UpdateStagingTables的值更新StagingCustomers表格 – Slee
然後David的回答是正確的。 – cadrell0