Create combinaison of field

G

Gilles P (FR)

I like to create a Query that combinate all the pair of value form two Tables

Table A Field A
A
B
C

Table M field M
m
n
o

I like to obtain by query a table Z
Field A field M
A m
A n
A o
B m
B n
B o
C m
C n
C o

How is the query that generate this ?

Thanks for your help

G.PROVOST
 
R

raskew via AccessMonster.com

Hi -
It's called a Cartesian Product. Pull both tables into your query. Remove
any joins. Select the desired field from tables A & M. Run the query and
it'll return all possible pairs.

For example, using Northwind's Orders (828 records) and Employees (9 records)
tables:

SELECT Orders.OrderID, Employees.LastName
FROM Orders, Employees
ORDER BY Orders.OrderID, Employees.LastName;

...returns 7452 pairs (828 * 9)

HTH - Bob
 

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