How to delete duplicate data from database table

Prem Tiwari - - Mysql, Oracle

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.

Prem Tiwari

Prem Tiwari is the founder of and also a professional developer and a blogger by hobby.

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.