Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query multiple fields for an exact match of record 1

Status
Not open for further replies.

LowBrow

Technical User
Jun 1, 2001
100
US
I have two tables:
TableA is a master list of names, addresses, phone numbers, etc. TableB is a volunteer list. I need to write a query such that:
From TableA select specific row where lastname, firstname, mailadd = specific row from TableB.
TableB contains inaccurate information and I need to compare parts of each record to the records in TableA to pull out possible corrected information. I hope this makes sense. Here is an example:
In TableA there would be a perfect record that had
LstName FstName StAdd City State
Doe John 1234 Eastwood St New York NY

In TableB I may have a record that has:
LstName FstName StAdd City State
Doe John New York NY

In this case, I would have my query search for a distinct record that had From Table:LstName, FrstName, City, State
= TableB LstName, FstName, City, State

I'm sure there has to be a way to write this query. If anyone has any ideas, please let me know.
Thanks!
 
[tt]select A.LstName
, A.FstName
, A.StAdd
, A.City
, A.State
, B.LstName
, B.FstName
, B.StAdd
, B.City
, B.State
from TableA A
inner
join TableB B
on A.LstName = B.LstName
and A.FstName = B.FstName
and A.City = B.City
and A.State = B.State [/tt]

rudy
SQL Consulting
 
Thank you very, very much! I thought I had tried this, but it kept returning matches of All last names, all first names, etc. (as though I had used OR instead of And). But this works perfectly! Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top