Horje
How to delete all Duplicate Rows except for One in MySQL

Editor warning: This solution is computationally inefficient and may bring down your connection for a large table.

NB - You need to do this first on a test copy of your table!

When I did it, I found that unless I also included AND n1.id <> n2.id, it deleted every row in the table.


Step-1: Login to Cpanel

First, Login to Your Cpanel

Output should be:

Step-2: Click on phpMYadmin

Second, Click on "phpMYAdmin" from Database

Output should be:

Step-3: Select a Database

Output should be:

Step-4: Finally Run Code

If you want to keep the row with the lowest id value:

DELETE n1 FROM table_name n1, table_name n2 WHERE n1.id > n2.id AND n1.name = n2.name

Output should be:




Related Articles
How to delete row id from 1 to 1000 in PHPmyAdmin PHPmyadmin Tutorial
How to delete all Duplicate Rows except for One in MySQL PHPmyadmin Tutorial
How to remove everything after a string by PHPmyadmin PHPmyadmin Tutorial


Read Full::
PHPmyadmin Tutorial
Category:
Web Tutorial
Sub Category:
PHPmyadmin Tutorial
Uploaded:
3 weeks ago
Uploaded by:
Admin
Views:
183
Tested on:
MySQL 5.1
Ref on:
View



Share on: