Query all records from two tables

  • Thread starter Thread starter Val
  • Start date Start date
V

Val

I have two tables. Production information in first table
delay information in second table. I am trying to create a
query that will show ALL information from both tables. Left
join query shows delay info, right join query shows
production info. Can I somehow join the two queries? I
would appreciate any information. Thank-you
 
Hi,


There is two way, either make a non matching query as the second part of an
UNION:


SELECT a.*. b.*
FROM a LEFT JOIN b ON a.id=b.id

UNION ALL

SELECT a.*, b.*
FROM a RIGHT JOIN b ON a.id=b.id
WHERE a.id IS NULL




The other solution is to make a table with all possible values involved


SELECT id FROM a UNION id FROM b


and make a table of it, say, All_ID, index its unique field (or make it a
primary key), id, then:


SELECT a.*, b.*
FROM (All_ID LEFT JOIN a ON All_ID.id=a.id)
LEFT JOIN b ON All_ID.id=b.id



will also make the full outer join you desired.




Hoping it may help,
Vanderghast, Access MVP
 
Thanks for the help,I appreciate it. You have given me many
options to work with.
 

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

Back
Top