1

Attempting to query based on a data extension called [Users], but I want to extract ALL the contacts that are also in the [Unsubscribe] data extension.

I thought it would be a simple 'NOT IN' function, but do I need to INNER JOIN, as well?

SELECT * FROM ENT.[Users] WHERE Email Address NOT IN ENT.[Unsubscribe]
2

First if that's the "Email Address" field, you would have to put it in brackets [Email Address]. I suspect there is no space between them (EmailAddress).

I would use this as I have found it to work well for me when excluding fields present in another DE.

SELECT 

t.Email, 
t.Platform_User_Id, 
t.First_Name, 
t.Last_Name, 
t.Created_At, 
t.Last_Login_At, 
t.platform 

FROM ENT.[Users] t

LEFT JOIN ENT.[Unsubscribe] u

ON t.EmailAddress = u.EmailAddress

WHERE u.EmailAddress IS NULL
3
  • That works. Only issue is that I couldn't use the '*' (select all) function as the query was using a JOIN. Thanks @data_kid – Tom Callahan Jul 7 '17 at 15:06
  • Follow-up Question: If I were to add another DE to exclude, would it look like this? SELECT ` t.Contact_Key,` t.Email, t.Platform_User_Id, t.First_Name, t.Last_Name, t.Created_At, t.Last_Login_At, t.platform FROM ENT.[Users] t LEFT JOIN ENT.[Unsubscribe] u ON t.Email = u.Email LEFT JOIN ENT.[Suppress] m ON t.Email = m.Email_Address WHERE u.Email IS NULL and m.Email_Address IS NULL – Tom Callahan Jul 7 '17 at 15:26
  • 1
    Should work :) updated my answer apologies for the oversight – Samuel Dare Jul 7 '17 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.