CREATE TABLE emails_temp AS SELECT * FROM emails WHERE 1 GROUP BY email; DROP TABLE emails; RENAME TABLE emails_temp TO emails;
$sql = "SELECT id,count(email) as etot FROM emails group by email having etot > 1"; $result = mysql_query( $sql );while( $row = mysql_fetch_array( $result ) ) { $id.= $row["id"].','; //$delem = "delete from emails where id = '".$row["id"]."'"; $delquery = mysql_query($delem); } $id=substr($id, 0, -1); $delem = "delete from emails where id in ($id)"; $delquery = mysql_query($delem);