I'm not a SQL Server expert and I'm struggling with this query. Can anyone help?
DELETE
FROM PPTMAILLISTC.dbo.emailTables
WHERE email IN (SELECT *
FROM PPTMAILLISTC.dbo.emailTables tab1
INNER JOIN PPTMAILLISTAB.dbo.emailTables tab2
ON tab1.email = tab2.email)
SQL Server Management Studio returns.
Msg 116, Level 16, State 1, Line 1
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Basically, there are 2 separate tables both called the same (dbo.emailTables
) in 2 separate databases (PPTMAILLISTC
and PPTMAILLISTAB
).
Where the both databases have the same results (which I can find out using the join i.e.)
SELECT *
FROM PPTMAILLISTC.dbo.emailTables tab1
INNER JOIN PPTMAILLISTAB.dbo.emailTables tab2
ON tab1.email = tab2.email
I want to delete the results of this join from PPTMAILLISTC.dbo.emailTables
.