Hi,
Indeed, a JOIN acts like an amplifier.
Table1 ' table name
f1 f2 ' fields
1 a
2 b
3 c ' data
Table2
g1 g2
1 one
1 un
1 uno
2 dve
SELECT TAble1.f1, Table1.f2, table2.g1, table2.g2
FROM table1 INNER JOIN table2
ON table1.f1=table2.g1
would return
f1 f2 g1 g2
1 a 1 one
1 a 1 un
1 a 1 uno
2 b 2 dve
we can "conclude" (it just a matter of how we look at the result, not really
a definition) that table1 first record had been amplified 3 times, since it
now appears three times in the result; its second record, amplified once, if
we can speak of amplification in such a case; and its third record, by 0
times ( eliminated ). Sure these "amplification" numbers, 3, 1, and 0, are
just the number of duplication of the MATCHING value ( table2.g1 ) as
specified by the ON clause.
So, as you found, 27 records were duplicated, so the amplification number
for those records was 2, and you get 27 additional extra rows in the
results.
How to solve the problem? First, are those duplicated values make sense? if
not, remove them from the table (and add a UNIQUE index on the field so that
this error won't occur anymore, since with the index, it will not allow the
presence of duplicated values).
If the duplicated data makes sense (for other reasons), you may try a
DISTINCT or a GROUP BY query. A GROUP BY query may selectively generated
groups (no duplicated values among the group) and take "some" representative
values out of the other fields not making the groups:
SELECT f1, MAX(f2), MAX(g2)
FROM table1 LEFT JOIN table2 ON table1.f1=Table2.g1
GROUP BY f1
would so produce
f1 f2 g2
1 a uno
2 b dve
3 c <null>
Hoping it may help,
Vanderghast, Access MVP
Kresha said:
Thanks for the help! I didn't realize it was so simple to fix what
records you wanted to keep. I know that I sound like a novice user, but I
have one more question. In Access, my parcel_polygon table has 20,640
records and the TAXDIGEST table has 25,119 records,... when I put them
together and keep all of parcel_polygon records, shouldn't I come up with
20,640 records???
Well, when I joined them, I got 20,667 records. Where could the other 27 records come from?
I did a query where access finds out how many duplictes there are and it
found 54 (27 times 2). For some reason Access is duplicating 27 records.
Is there a reason for this? I don't need access adding in more records.
What do I need to do to fix the problem?