Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delete duplicate records from master table mysql

Tags:

php

mysql

I have 2 mySQL tables (table Master and table Backup) Some rows are copied to backup table and some not...

Now I need to delete those all rows from Master Table which are availble in Backup table with single query, coz approx. 700k+ rows are in both tables

like image 709
user1840242 Avatar asked Jan 25 '26 20:01

user1840242


1 Answers

Something like:

DELETE FROM master_table WHERE id IN (SELECT id FROM backup_table)

Of course it needs unique key on id field to work

like image 181
dev-null-dweller Avatar answered Jan 27 '26 10:01

dev-null-dweller



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!