Query based on multiple Tables

  • Thread starter Thread starter Dave M
  • Start date Start date
D

Dave M

Hello,

I am trying to make a query identifying discrepincies between two tables.
Each table has a difference database extract as the info.

I am trying to match one indicator in each table and find the discrepancies
in a second indicator and list a third indicator.

How do I do this?

Thanks in advance for your help, I've used this forum before for Excel
questions and always had helpful responses.
 
You can use LEFT JOIN or a RIGHT JOIN, they are basically the same.
If you have two tables with a common key in table1 and table2,
then you can join them like this:

SELECT *
FROM tbl1 LEFT JOIN tbl2
ON tbl1.Key = tbl2.Key
WHERE tbl2.key IS NULL

The above query will show you all records from table 1 but not in tabl2.
Conversely, you can do

SELECT *
FROM tbl1 RIGHT JOIN tbl2
ON tbl1.Key = tbl2.Key
WHERE tbl1.key IS NULL

To get the records in tabl2 that are not in table1.

You can also perform these two queries in the QBE window. Simply select
the tabes and then join them on the key, then right click on the the
link and select the join type.


Ben
 
Back
Top