Case 1
Run Query->
SELECT * FROM OriginalTable WHERE OriginalTable.OrderID not IN (SELECT NewTable.OrderID FROM NewTable)
Case 2
Run Query->
SELECT * FROM NewTable WHERE NewTable.OrderID not IN (SELECT NewTable.OrderID FROM NewTable)
Case 3
Run Query->
SELECT * FROM OriginalTable WHERE OriginalTable.OrderID IN (SELECT NewTable.OrderID FROM NewTable)
您也可以在兩個表中運行加入像這樣只得到相同的訂單ID
Case 3
SELECT * FROM OriginalTable JOIN NewTable ON OriginalTable.OrderID = NewTable.OrderID
,如果你想找出哪些記錄在兩個表是不同的,那麼你可以運行:
SELECT * FROM OriginalTable JOIN NewTable ON OriginalTable.OrderID = NewTable.OrderID WHERE OriginalTable.OrderID IS NOT IN (SELECT NewTable.OrderID FROM NewTable) OR WHERE OriginalTable.OrderID IS NOT IN (SELECT OriginalTable.OrderID FROM OriginalTable)
Yes..Select與左連接/右連接...我沒事,即使我需要運行爲每個用例一個查詢。我還沒有解決第三個用例。 – Pankaj
爲什麼不把它納入問題? –
@Pankaj看看我的解決方案,並嘗試這些查詢,並回到我的問題是否解決問題。 – Vish