Query Join on Multiple Field Indexes

J

John D

I have one Table with a 2 field Primary Key. A second Table has a 2 field
Index. Each of the 2 fields is defined the same in both Tables.

I want to Join the two Tables in a query on these 2 fields - one a Primary
Key in one Table, the other a 2-field non-Primary Index (known as a Secondary
Key in other databases).

But - I can't figure out how to do that on the query design form. Can anyone
help. Thanks in advance.

John D
 
S

strive4peace

Hi John,

SELECT T1.[fieldname1], T1.[fieldname2], T2.[fieldname3]
FROM [TableName1] as T1
INNER JOIN [TableName2] as T2
ON T1.[fieldname1] = T2.[fieldname1]
AND T1.[fieldname2] = T2.[fieldname2]

Warm Regards,
Crystal

remote programming and training

Access Basics
8-part free tutorial that covers essentials in Access
http://www.AccessMVP.com/strive4peace

*
:) have an awesome day :)
*
 
J

John D

Crystal - turns out I made a really dumb mistake - I had added an extra
character into one of the fields in one table as a category code some months
ago, but forgot about it and didn't notice it when I was trying to make the
query work. And, of course, it couldn't work because the values were 1
character different.

Dumb - oh well. Now, of course, it works just fine. Thanks.

John D
 

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