0

I have:

[Data extension A] with CustomerID(PK)

[Data extension B] with SubscriberKey(Nullable) which has the same value as CustomerID

Attempting to get all the customers from [Data extension B] that don’t exist in [Data extension A]

I thought it would be a simple 'NOT IN' function, but it doesn't seem to work.

SELECT 
SubscriberKey

FROM [Data extension B]

WHERE SubscriberKey NOT IN (SELECT CustomerID FROM [Data extension A])
2

Did you try using left join:

SELECT 

B.SubscriberKey

FROM [Data extension B] B 
LEFT JOIN [Data extension A] A ON A.CustomerID = B.SubscriberKey

WHERE 
A.CustomerID IS NULL 

This image explains joins with examples.

enter image description here

Image credits: Visual Representation of SQL Joins

  • Thanks, it works with the join – Duicug Oct 21 at 10:26
  • Glad it helped. Don't forget to accept the answer ;) – Rachid Mamai Oct 21 at 11:09
  • Can you please not copy images from stackexchange? Instead you should be linking to the existing stackexchange topic. This would be the right thing to do in many ways. Copyright, credit to the author etc., credit to the person that wrote the answer on stackexchange... – Johannes Schapdick Oct 21 at 12:25
  • How can you tell that i've copied the image from stackexchange? Try typing "sql joins" in google, the first image you'll get is the image i've joined in my response. In addition, I think that the answer is so simple and generic that I prefer answering it directly than looking for a similar question/answer in stackexchange, it takes less time.. – Rachid Mamai Oct 21 at 12:29
  • I am just trying to tell you that this build has even a copyright claim on the picture and i am not aware if you paid attention to copyright laws. – Johannes Schapdick Oct 21 at 12:57

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.