Solved

MY SQL Delete with Inner Join

Posted on 2014-02-16
3
940 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
Comment Utility
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
Comment Utility
Perfect thanks was missing that extra line much appreciated
0
 
LVL 3

Expert Comment

by:stevejacob68
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

6 Experts available now in Live!

Get 1:1 Help Now