Re: Trouble with 2 tables connected by reference table
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Wed, 30 Apr 2008 12:00:21 -0400
You probably have duplicated values ( 3 times ) under the field of one of
the table implied by the join.
table1.f1 table1.f2
a 1
a 2
table2.g1 table2.g2
a 10
a 20
SELECT * FROM table1 INNER JOIN table2 ON table1.f1=table2.g1
f1 f2 g1 g2
a 1 a 10
a 1 a 20
a 2 a 10
a 2 a 20
since each matching records in table1 and table2, matching the condition:
table1.f1=table2.g1
will be 'joined' (horizontally) with each record it matches in the other
table. SO, here, the result got 4 records. Add a third record in table2:
a 30
and the result will get 6 records. So, from the table1 point of view, it
would like as if all its records were 'multiplied' by 3; while, from table2
point of view, all records would appear to have been multiplied by 2.
Hoping it may help,
Vanderghast, Access MVP
"jwb96" <jwb96@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:C5789649-2B19-40EF-83AD-D9076F0B716C@xxxxxxxxxxxxxxxx
I'm trying to summarize similar data from two tables in one query but am
having issues when I bring in the second table.
I have an activity table, with storeId, activityDate, activityA and
activityB. I use two reference tables (dateRef, to roll up activityDate
into
weeks and months; and storeRef, to display a storeName) to make the query
output summarized and readable. This works fine.
I then also want to bring in data from the transaction table, which has
transactionCount, transactionDate and storeId. I create relationships
from
the existing reference tables to the transaction table, and while the
transactions calculate fine, all of the sudden the activity data from the
first table gets multiplied by three.
There are other columns in the activity and transaction tables that make
the
rows unique - in other words, I can't simply join the tables together
without
the reference tables. Currently, my relationships look like the reference
tables are acting as a bridge between the fact tables.
Any suggestions on what could be causing the troubles?
Thanks,
Jim
.
- Follow-Ups:
- References:
- Prev by Date: RE: Query Criteria
- Next by Date: convert to number
- Previous by thread: Trouble with 2 tables connected by reference table
- Next by thread: Re: Trouble with 2 tables connected by reference table
- Index(es):
Relevant Pages
|