How to remove duplicate entries from a table ?

Removing Duplicate entries from Mysql database table are really simple. I have found some times interviewer ask tricky questions like this. PHP-MYSQL Beginners  just be careful !

It can all be done with three manual SQL steps! No PHP Coding required, and it works with MySQL 4 and above versions.

Step One

CREATE TABLE MyNewTable as
SELECT * FROM MyOldTable WHERE 1 GROUP BY [column to remove duplicates by];

Step Two – You hate to keep old table with all the duplicate entries, so drop it!

DROP TABLE MyOldTable;
RENAME TABLE MyNewTable TO MyOldTable;
Share

One thought on “How to remove duplicate entries from a table ?

Leave a Reply

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