Reputation: 175
I have to find the differences between two tables. Both have the same composite keys.
So Table A is:
Vendor Material
Vendor1 Mat1
Vendor1 Mat2
Vendor1 Mat3
Vendor 2 Mat 4
And Table B is:
Vendor Material
Vendor1 Mat1
Vendor1 Mat2
Vendor1 Mat3
Vendor1 Mat4
Vendor2 Mat4
I need to figure out how to get the result Vendor1 Mat4.
I tried
Select TableB.Vendor, TableB.Material From TableB,TableA, where TableB.Vendor <> TableA.Vendor AND TableB.Material <> TableA.Material;
But this doesn't help me, because I get a lot more results than expected.
Upvotes: 0
Views: 57
Reputation: 175
SELECT TableB.Vendor , TableB.Material
FROM TableB LEFT JOIN TableA on TableB.Vendor =TableA.Vendor and TableB.Material = TableA.Material
WHERE tableA.vendor IS NULL
Upvotes: 0
Reputation: 69470
This query should give you the result:
Select TableB.Vendor TableB.Material
from TableB join TableA on TableB.Vendor =TableA.Vendor and TableB.Material = TableA.Material
where tableA.vendor is null;
Upvotes: 2