Not sure I'm going about this in the correct way, but I guess its exploring what does what!
I have a table called contacts, within which there are duplicate rows (first and last are the same with different ids). I have a page where I display each of the duplicates using the following code. How it currently works is it displays each of rows in the table with the same surname, regardless of if they have the same first name.
What I dont know is how would be best to go about showing only those records where there are two or more results for rows with the same first and last name.
Any ideas from anyone please?
$q = "SELECT first, last FROM contacts GROUP BY last ORDER BY last, first";
$result = mysql_query($q,$conn);
while($row = mysql_fetch_assoc($result))
{
$q2 = "SELECT * FROM contacts WHERE last = '$row[last]' ORDER BY first";
$result2 = mysql_query($q2,$conn);
$count = mysql_num_rows($result2);
while($row2 = mysql_fetch_assoc($result2))
{
if($count > 1)
{
// Code to display the duplicates