Query Show All

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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.
 
Back
Top