Solved

Access sql

Posted on 2014-09-29
4
540 Views
Last Modified: 2014-10-01
There are three tables – table specific to item, table specific to distributor and a join table that has existing combination of item and distributor. Usually use fill in the jon table to with the possible (existing combination of item and the distributor level where they are sold. I need a union query oof some sort that returns a Cartesian product of the two tables – items Distributor join table and distributor List table  - so that for example –
If item T23 was listed with only distributor D01 in the join table >> then the query returns a total of 5 rows – with the possible combination of that item and all the other distributor list but puts 0 for the price. See attached image and DB.
Thank you
superDB.accdb
superDB-QueryResults.jpg
0
Comment
Question by:Rayne
  • 2
  • 2
4 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 40351067
You don't need a Union.  A union query stacks lists on top of each other so all rows from tblA are returned followed by all rows from tblB.  Both tblA and tblB MUST have the same format.  A join compares two tables and returns matches (inner join), rows from tblA without rows in tblB (left join), rows from tblB without rows in tblA (right join), all rows from tblA matched to every row in tblB (cross join or Cartesian product).

So to create a Cartesian Product, add the two tables to the QBE.  Select the columns you want from each table.  Do NOT draw a join line.
0
 

Author Comment

by:Rayne
ID: 40351145
A and B have different formats because they are different tables
0
 

Author Comment

by:Rayne
ID: 40351147
so i cant change thier column order or numbers
0
 
LVL 36

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40352201
I said you don't need a union so you don't need to worry about column format or order.  You need a query that creates a Cartesian Product.  Add both tables to the QBE.  Do NOT draw a join line.  Select the columns you want from either table.
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question