I am attempting to create a utility to display duplicate entries in a table. I did a search and found info about finding duplicate entries based on a single column (such as duplicate email addresses held in a 'email' field). However, I need to do this "duplicate search" based on 2 fields in the table:
I have a table of names (and other contact info). There is a field for 'FirstName' and a field for 'LastName'. I need to find (and display) any names that are duplicates in those two fields. Ex: Two entries with FirstName=John, LastName=Smith.
This issue arose by virtue of uploading data from two large, but equally incomplete databases of names and information. So I'm now trying to identify duplicate entries that were created.
I would like to think that I could join the two fields together as a single field, then compare for duplicates of the concat, but no luck:
$sql = "SELECT *, trim(concat(FirstName, LastName)) as AlumName, COUNT(AlumName) > 1 FROM classlist GROUP BY LastName";
The issue however is that it gives me a "AlumName" column not found error.
At present, the best I've been able to make functional is:
$sql = "SELECT *, COUNT(LastName) > 1 FROM classlist GROUP BY LastName"; // display where last name count > 1
The issue with this one, is that it only identifies duplicate last names (Such as Smith). But those aren't necessarily problems - Joe SMITH is not the same as Jane SMITH.
Please help!!
Thank you in advance.