How to delete duplicate data from database table

| Last Updated: | In: 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.


About: Prem Tiwari

Prem Tiwari is the founder of freewebmentor.com and is a professional developer who has vast experience in PHP and open source technologies. Apart from this, he is a blogger by hobby and also he has been a regular speaker of WordPress sessions in various IT Companies.


You may also like:


,