Delete Duplicate Rows In Mysql With PHP

$dupq = mysql_query("SELECT * FROM `db`");
$dups = mysql_fetch_array($dupq);
foreach($dups as $dup){
mysql_query("DELETE FROM db WHERE duplicate_COLUMN='".$dup['duplicate_column']."' AND id!='".$dup['id']."'");
}

duplicate_COLUMN – Name of column and $dup[‘column_name’] delete duplicates which include same column data.

Leave a Reply

Your email address will not be published. Required fields are marked *