Solved

Access sql

Posted on 2014-09-29
4
515 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 35

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 35

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
My experience with Windows 10 over a one year period and suggestions for smooth operation
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

810 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