Tag: data manipulation
MySQL – Removing duplicate rows from a table
by Jay on May.19, 2011, under MySQL
This save me loads of hassle this morning as I ran my script which populated an important table with duplicate entries which should not be there.
This is a must share for those who fall into the same problem.
Open up a mysql editor and paste in the following (don’t forget to edit for your table names)
CREATE TABLE new_table as SELECT * FROM old_table WHERE 1 GROUP BY [column to remove duplicates by];
Drop the old table and rename the new one – job done!
Quick, easy and slightly painless.