Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Another Noob Question

Author  Topic 

jatrix32
Starting Member

49 Posts

Posted - 2010-09-15 : 13:04:56
I have a main table (Subscription) and I want to delete users whose email addresses matches the email address of another table.

Not sure if this is right:

DELETE
FROM SUBSCRIPTION
WHERE SUBSCRIPTION.sub_email = YSU_Update.sub_email

Would this work?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 13:19:07
DELETE s
FROM SUBSCRIPTION s
JOIN YSU_Update y
ON s.sub_email = y.sub_email

Please run it with a SELECT first though:

SELECT s.*
FROM SUBSCRIPTION s
JOIN YSU_Update y
ON s.sub_email = y.sub_email


Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jatrix32
Starting Member

49 Posts

Posted - 2010-09-15 : 13:38:30
That worked, thanks!!!
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-09-15 : 13:49:15
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -