Solved

MY SQL Delete with Inner Join

Posted on 2014-02-16
3
973 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Creating and Managing Databases with phpMyAdmin in cPanel.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

832 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