Link to home
Start Free TrialLog in
Avatar of exp vg
exp vg

asked on

Access - Join on Two Fields, With and Without Third Field in Output

I have two tables with 15 fields, of which 3 are Last Name, First Name, and ID.

I join Last Name from Table A, to Last Name form Table B, and the same for First Name. I also then Group By to get single row values.

When I join just on names, I get an output row count of 1900 (ID is not in the query).

When I join on the two fields, Last Name, First Name - but this time have ID in the output but not joined, I get an output row count of 2100.

What i am trying to understand is why does the count go up when ID is included in Design View, but is not being joined between Tables A and B.

Thank you.
Avatar of exp vg
exp vg

ASKER

I should add that the row count does not always increase after a third field is in the output (but not joined) - in another instance there was a decrease.

I just want to understand why the number changes after additional fields are joined in design view, but are not directly joined.

Thank you.
SOLUTION
Avatar of Hamed Nasr
Hamed Nasr
Flag of Oman image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exp vg

ASKER

The reduction in count makes sense if there are duplicates, but not when the count increases. I also just tried adding more fields to design view - but not a direct joined.  Now I see the counts increase.

Thanks.
you have records with the same Last Name and First Name BUT, different ID
If adding a new field to Group By, adds more records, then expect few duplicates including the fields but last.
Avatar of exp vg

ASKER

If they are different, will the row count increase or decrease - again these additional fields are not joined.

My initial take is they will increase because more rows are added to account for the different values. However, why do I see a decrease at times?

Thanks.
Avatar of exp vg

ASKER

Ok - I see what is happening. More fields are added since there is not a definite join - and more likely an increase. The most direct and accurate ways is to join on just Last and First Names to avoid this crossover with additional fields that are not the same.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exp vg

ASKER

Thanks Rey - please confirm that the code above accounts for the join in design view only happens between first and last name.
Avatar of exp vg

ASKER

These explanations make sense.

Thanks so much.
Avatar of exp vg

ASKER

Thank you.
All depends on what you plan to do.

Our comments include assumptions on your behalf which may not be accurate,

If you have tables:
t1  3 records, t2 4 records.

Then INNER JOIN may produce up to 4 records.
Without a join you get 12 records.