Query 2 tables, find records where the key matches

B

Brian Langley

I have:

Table 1
Name SSN Vendor

Table 2
Name SSN Address

Table 2 has ~4200 records, Table 1 ~800. I want to pull the 800 records from
Table 2 that match the SSNs on Table 1.

The tables were joined as a 1-1 by SSN, and both tables use the SSN as the
Primary Key. The SSNs are stored as Text with matching input masks and are
saved with the dashes in the table, if that's releveant.

Thanks for any help anyone can give me- I'll appreciate it.
 
J

Jason Lepack

If you have a 1-to-1 relationship then just store it in the same
table...
Name, SSN, Vendor, Address

However, for now:

SELECT
A.SSN,
A.[Name],
A.Vendor,
B.Address
FROM
[Table 1] AS A
INNER JOIN [Table 2] AS B
ON A.SSN = B.SSN

Cheers,
Jason Lepack
 
B

Brian Langley

Still coming up blank...I used the table names in place of Table 1/2, as
well as subbed in the Table Names for the A/B 'aliases' (or w/e they are
properly called). Could there be some error in the SSNs themselves? They
look okay and they cut/paste the same into Notepad...

Both tables came from different sources which is why I'm stuck trying to
mate the two like this.


Jason Lepack said:
If you have a 1-to-1 relationship then just store it in the same
table...
Name, SSN, Vendor, Address

However, for now:

SELECT
A.SSN,
A.[Name],
A.Vendor,
B.Address
FROM
[Table 1] AS A
INNER JOIN [Table 2] AS B
ON A.SSN = B.SSN

Cheers,
Jason Lepack

I have:

Table 1
Name SSN Vendor

Table 2
Name SSN Address

Table 2 has ~4200 records, Table 1 ~800. I want to pull the 800 records
from
Table 2 that match the SSNs on Table 1.

The tables were joined as a 1-1 by SSN, and both tables use the SSN as
the
Primary Key. The SSNs are stored as Text with matching input masks and
are
saved with the dashes in the table, if that's releveant.

Thanks for any help anyone can give me- I'll appreciate it.
 
J

Jason Lepack

There's only one possiblity. That is that the SSNs are not matching.
You need to manually check and see that the data is the same and
figure out why they are different. It could be based on how you
perform the import.

I don't have enough information to give you a solid answer.

Cheers,
Jason Lepack

Still coming up blank...I used the table names in place of Table 1/2, as
well as subbed in the Table Names for the A/B 'aliases' (or w/e they are
properly called). Could there be some error in the SSNs themselves? They
look okay and they cut/paste the same into Notepad...

Both tables came from different sources which is why I'm stuck trying to
mate the two like this.




If you have a 1-to-1 relationship then just store it in the same
table...
Name, SSN, Vendor, Address
However, for now:
SELECT
A.SSN,
A.[Name],
A.Vendor,
B.Address
FROM
[Table 1] AS A
INNER JOIN [Table 2] AS B
ON A.SSN = B.SSN
Cheers,
Jason Lepack

- Show quoted text -
 

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