Solved

MY SQL Delete with Inner Join

Posted on 2014-02-16
3
952 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
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now