我需要有关此查询的帮助...
SELECT FIRST_NAME, LAST_NAME, test.EMAIL
FROM test
INNER JOIN suppression ON suppression.EMAIL = test.EMAIL
AND NOT EXISTS (select * from suppression)
我想要来自表“test”的所有记录,其中表“suppress”不包含类似的记录。
答案 0 :(得分:3)
我个人更喜欢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)
祝你好运。
答案 1 :(得分:3)
使用LEFT JOIN
SELECT a.*
FROM test a
LEFT JOIN suppression
ON suppression.EMAIL = a.EMAIL
WHERE suppression.EMAIL IS NULL
要充分了解联接知识,请访问以下链接: