Howto remove duplicates in MySQL

Just imagine you have a table with thousands of entries, many of them has duplicated Email from example, it’s the best practice to remove all duplicates. With MySQL, following SQL snippet does the job well:

alter ignore table bad_table2 add unique index `unique_index` (Email);
# And then remove the added index.
alter table bad_table2 drop index `unique_index`;
Advertisements

About Jones Lee

Nothing much about me..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: