Query Show All

G

Guest

How can I make a query the will show all the product type from 2 different
tables. 1 table holds the budget and the other one holds the sales. Not all
the productytype are the same from this 2 table but i wanted that everything
will show up in a single query. Thank you for any help.
 
D

Douglas J. Steele

You can use two different LEFT JOINS and UNION the subqueries together:

SELECT Budget.Field1, Budget.Field2, Sales.Field1, Sales.Field2
FROM Budget LEFT JOIN Sales
ON Budget.Id = Sales.Id
UNION
SELECT Budget.Field1, Budget.Field2, Sales.Field1, Sales.Field2
FROM Sales LEFT JOIN Budget
ON Budget.Id = Sales.Id

Since you're using UNION (not UNION ALL), any duplicate records will be
eliminated.
 

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