我需要有关此查询的帮助...
SELECT FIRST_NAME, LAST_NAME, test.EMAIL
FROM test
INNER JOIN suppression ON suppression.EMAIL = test.EMAIL
AND NOT EXISTS (select * from suppression)
我想要表“test”中的所有记录,其中表“suppression”不包含类似的记录。
采用LEFT JOIN
SELECT a.*
FROM test a
LEFT JOIN suppression
ON suppression.EMAIL = a.EMAIL
WHERE suppression.EMAIL IS NULL
要全面了解联接,请访问以下链接:
我个人更喜欢这种LEFT JOIN
IS NULL
方法,但这里有一个替代方法NOT EXISTS
:
SELECT FIRST_NAME, LAST_NAME, EMAIL
FROM test
WHERE NOT EXISTS (SELECT * FROM suppression WHERE email = test.email)
也不能真正离开NOT IN
:
SELECT FIRST_NAME, LAST_NAME, EMAIL
FROM test
WHERE Email NOT IN (SELECT Email FROM suppression)
祝你好运。