MySQL Forums :: General :: Duplicate records - Show records that has same FIRSTNAME & LASTNAME
Duplicate records - Show records that has same FIRSTNAME & LASTNAME
Posted by: Roy Haryanto
Date: March 04, 2008 09:00PM
I am currently facing a problem where I wanna search for duplicate records in the database by firstname & lastname fields.
For the sake of simplicity, let's assume that the firstname and lastname combination is unique to each individual, that means there will be no person with the same firstname& lastname.
My current solution is sloppy at best and it is extremely slow too.
I used PHP to query for each single records (total = 2000+ queries).
e.g. SELECT * FROM users WHERE firstname LIKE $firstname AND lastname LIKE $lastname
This solution is not scalable too. If the userbase grows to the high 5 digits, the system is gonna choke for sure.
Here is the structure of the 'users' table.
user_id | firstname | lastname
Is there any elegant way of solving this problem?
Here is the pseudo code of what I am trying to accomplish.
SELECT * FROM users
WHERE ( number of users which the same firstname & lastname >0 )
Thanks in advance, guys.
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.