Page 2 of 2

Posted: Fri Aug 26, 2005 10:32 am
by waskelton4
Using a combination of replies here is what I did....


first used the sql..

Code: Select all

SELECT COUNT(t1.ID) AS siblings FROM table t1 NATURAL LEFT JOIN table t2 GROUP BY t1.ID HAVING siblings > 1
and put the ID field of all the dupes into an array. then used the code..

Code: Select all

$x = 0;
foreach($dupes as $id) {
	$sql = "DELETE FROM table WHERE ID = $id LIMIT 1";
	
	if(mysql_query($sql)) {
		$x++;
	}
}

echo "$x duplicates deleted";
No matter how many duplicates there are this works.. you just have to keep refreshing the page and each time it will remove one of the dupes.

Thanks for your help all!

Will