Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MY SQL Delete with Inner Join

Posted on 2014-02-16
3
Medium Priority
?
1,035 Views
Last Modified: 2014-05-17
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
0
Comment
Question by:ncomper
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 39863050
reading the technical reference:
http://dev.mysql.com/doc/refman/5.1/en/delete.html

you want to write it like this:
delete activecampaign.em_exclusion
from from activecampaign.em_exclusion
Inner join activecampaign.em_subscriber
ON em_exclusion.email = em_subscriber.email 

Open in new window

0
 
LVL 5

Author Closing Comment

by:ncomper
ID: 39863069
Perfect thanks was missing that extra line much appreciated
0
 
LVL 3

Expert Comment

by:stevejacob68
ID: 40071943
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)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question