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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple address, need to select one

Status
Not open for further replies.

Noah114

Technical User
Mar 31, 2005
59
0
0
US
I have a query that pulls physician info. I then trim the doctors name due to the fact that the same doctor will be in the data multiple times with slight variances in info. For example;

Robert Hull 150 West Chester Dr,
Robert Hull 150 W. Chester Dr.

I trim and store the name in a separate table, for example simply

Robert Hull

How can I great a query that will grab on address, either or is fine, but when I run the data it dupes.
 
In you new table, set the "Name" field to accept no duplicates. By doing so, your query will fail when attempting to write the second "Robert Hull" record, but will continue looping through the rest of the table.


Randy
 
Try something like:
[tt]SELECT tblDoctors.DrName,
(Select Top 1 [Address] from tblAddresses
Where tblAddresses.ID=tblDoctors.ID) AS 1stAddress
FROM tblDoctors;[/tt]
 
Code:
SELECT D.DrName, MAX(A.Address) As [TheAddress]

FROM tblDoctors D LEFT JOIN tblAddresses A
     ON D.DrName = A.DrName

Group By D.DrName
Use a LEFT JOIN just in case there are Doctors who don't have an address defined.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top