Query based on multiple Tables

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.
 
B

Ben

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top