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.

Recommended Posts:


Prem Tiwari

An engineer by profession and a passionate blogger by heart. Founder of FreeWebMentor.com (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: ,

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Solved Programs