I need a PHP function that deletes duplicate rows from MySQL database table. For example, I have a table like this:
I tried the following without success:
$find = mysql_query("SELECT * FROM users");
while ($row = mysql_fetch_assoc($find))
{
$find_1 = mysql_query("SELECT * FROM users ");
if (mysql_num_rows($find_1) > 0) {
mysql_query("DELETE FROM users WHERE ID =$row[num]");
}
I need to delete this duplicate rows and Keep only one of them only using PHP (and not my SQL database). Is there a way to do this?