Link to home
Start Free TrialLog in
Avatar of ncomper
ncomper

asked on

MY SQL Delete with Inner Join

HI,  I have a query below which basically finds duplicates email addresses across 2 tables.  The results of this I would like to delete from the em_exclusion table.  I.e for every row that is returned from the below query I would like to delete from the exclusion table any row that has an email address duplicate with the em_subscriber table.

I have googled around for this and watched YouTube videos and cant find anything on deleting the results of an "Inner Join"

select * from activecampaign.em_exclusion
Inner join activecampaign.em_subscriber
ON em_exclusion.email = em_subscriber.email


Thanks  all
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ncomper
ncomper

ASKER

Perfect thanks was missing that extra line much appreciated
Hi,
Use this statement to delete emails
DELETE activecampaign.em_exclusion, activecampaign.em_subscriber from table_name1,table2
where (select * from activecampaign.em_exclusion inner join activecampaign.em_subscriber ON em_exclusion.email=em_subscriber.email)