I'm trying to compare 2 table that have all the same columns in them in 2 different databases. The databases are on the same machine, and this is all in SQL database. I'm trying to retun results from table 2 that do not exist in table 1. The important column is called Stock.
Lets assume the names as are follows. DB1 and DB2 as the 2 databases. The table name for both is Vendor THe column is Stock
If I use this example I get no results
Select * From DB2.Vendor
Where (Stock != Stock)
Except
Select * From DB1.Vendor
Second Idea (this gives me an error)
Select * From DB2.Vendor
Union
Select * From DB1.Vendor
Group by Vendor.Stock
If you have a diffrent suggestion great Thanks in advance.
1条答案
按热度按时间tnkciper1#
You can Left join or Exists
Left join
Exists