Finding duplicates using last name & first 3 letters

marthacasting

Registered User.
Local time
Yesterday, 20:24
Joined
Oct 17, 2011
Messages
67
I need, please, to create a query that will pull duplicate names out of my db.
I would like it to pull all names that have:
duplicate LastName and duplicates of the first 3 letters of the FirstName.

For example, if I had the names:

Bland, Abe
Brown, Abe
Brown, Bill
Buster, Jon
Buster, Jonathon

I would like my query to return only Buster, Jon and Buster, Jonathon.

Is this possible?
Thank you!
 
Code:
Select lastname, left( firstname,3) 
from yourtable 
group by lastname, left( firstname,3) 
having count(*) > 1

This query will pull the duplicate names from your database giving Buster, Jon
Join this back to your source table to extract the full names.
 
Thank you.
Two questions, please:
1. I am still getting (for example)
Buster, Jon
Buster, Sam
Buster, Will

2. I don't know what you mean by: Join this back to your source table to extract the full names. (I am pretty new at this!). Will this resolve my #1 above?!

Thank you!
 
That means that you have dups for those names...

What you do to "join back" is to show the duplicates.
I.e. Save the first query as "qryFindDups"
Code:
Select lastname, left( firstname,3)  as Char3FirstName
from yourtable 
group by lastname, left( firstname,3) 
having count(*) > 1

Make a new query:
Code:
Select lastname, firstname, left( firstname,3) as Char3Firstname
from yourtable
Save this as "qryJoinBack"

Make a new query:
Code:
Select qryJoinBack.*
from   qryJoinBack
inner join qryFindDups on qryJoinBack.Char3Firstname = qryFindDups.Char3FirstName
and qryJoinBack.Lastname = qryFindDups.lastname
 
Last edited:
I'm sure Martha will spot this but just in case there is an as missing in the Select of qryjoinback

Brian
 

Users who are viewing this thread

Back
Top Bottom