Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access sql

Posted on 2014-09-29
4
Medium Priority
?
585 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 40

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 40

Accepted Solution

by:
PatHartman earned 1000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

916 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