Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete Duplicate SQL Records

Tags:

sql

duplicates

What is the simplest way to delete records with duplicate name in a table? The answers I came across are very confusing.

Related:

Removing duplicate records from table

like image 311
Bryan Avatar asked Jun 22 '26 05:06

Bryan


1 Answers

I got it! Simple and it worked great.

delete 
   t1 
from 
   tTable t1, tTable t2 
where 
   t1.locationName = t2.locationName and  
   t1.id > t2.id 

http://www.cryer.co.uk/brian/sql/sql_delete_duplicates.htm

like image 69
Bryan Avatar answered Jun 24 '26 19:06

Bryan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!