Thursday, December 16, 2010

Remove Duplicate Entries in Mysql table

Remove Duplicate Entries in Mysql table
To remove duplicate entries is to simply add a UNIQUE index to the current
table and thereby let MySQL do the hardcore identification and deletion job.

syntax

ALTER IGNORE TABLE TABLE_NAME ADD UNIQUE INDEX (COLUMN_NAME)

Example:

ALTER IGNORE TABLE duplicate ADD UNIQUE INDEX(a,b);

duplicate --->tablename

a,b -----> column name

No comments:

Post a Comment