Example my db structure olddb & newdb
newdb
ID email Name
-----------------------
1 john@yahoo.com John
2 peter@yahoo.com Peter
olddb
ID email
-------------------
1 john@yahoo.com
2 peter@yahoo.com
3 rambo@hello.com
4 super@duper.com
Now I want compare olddb with newdb and delete from olddb which email doesn’t have email in newdb
Let me know
DELETE FROM olddb, newdb
USING olddb
INNER JOIN newdb USING(email)
WHERE olddb.email <> newdb.email
This will give you a list of all emails from
oldtblwhich are not onnewtbl:Note:
oldtblandnewtblbecause I found your naming scheme confusing. We are talkind about tables, not databases.To delete those rows on
oldtbl, just changeSELECT *withDELETE.