I'm trying to compare two tables in MS Access using SQL. Each table has two columns. TableA has less rows than TableB and everything in TableA should also be in TableB. I would like to check that the rows in TableA are identical to the corresponding rows in TableB by displaying the rows that do not match up.
Here's where I run into a problem. I know how to compare the rows, but not how to compare the columns simultaneously. So right now if the rows in column1 of TableA match up to the rows of column1 in TableB, my query comes up empty even if some rows in column2 of TableA do not match up to some rows of column2 in TableB, and vice versa.
This is my current (generic) SQL code:
SELECT TableA.*
FROM TableA LEFT JOIN TableB ON TableA.column1 = TableB.column1
WHERE TableA.column1 Is Null;
Does anyone know how to modify this code to check both columns simaltaneously? I want the columns to be treated as one joined entity rather than as separate ones.
Thank you!
Edit: I figured out how to do it. A couple of the answers put me on the right path, but none of them were complete. This is what I ended up doing. Perhaps it will help someone else.
SELECT TableA.*
FROM TableA LEFT JOIN TableB ON TableA.column1 = TableB.column1
AND TableA.column2 = TableB.column2
WHERE TableA.column1 Is Null OR TableA.column2 Is Null;