How to delete duplicate data from database table

Hi friend, today i am going to share How to delete duplicate data from database table. For preventing from duplicate entries in datatbase table you cna use PRIMARY KEY or UNIQUE Index on table with fields. Bellow example show how to create UNIQUE Index in mysql database. If you have created fname and lname is UNIQUE index, then the users table will not insert duplicate entries like you can’t insert two records with same fname or lname.

Delete duplicate entries from database

If you have not created UNIQUE index in your database on time of created table and now you have lots of duplicate entries in database table. so don’t worry about it you can delete the duplicate entries by using bellow mysql query.

I will create a temporary table to holding the entries of users table group by fname, and then remove all duplicates entries which are not present in temporary table.

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts:

Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of (A Programming blog for beginners), Tech Speaker at various forums. A part from this he is an open source enthusiast, WordPress Lover, Blogger, SEO, and Growth Strategic.

Article Tags: ,