我正在尝试运行此查询
select from_ from uploaded_emails1
where uploaded_emails1.from_ != 'test@email_domain.com'
and uploaded_emails1.from_ not in candidate_emails1.email
但我收到错误No such table candidate_emails1.email
。但是如果我运行select email from candidate_emails1
它运行正常。
我做错了什么?
答案 0 :(得分:2)
别名candidate_emails1未在您的sql中定义
试
select from_ from uploaded_emails1
where uploaded_emails1.from_ != 'test@email_domain.com'
and uploaded_emails1.from_ not in(select emails from candidate_emails1)
答案 1 :(得分:0)
尝试:
SELECT from_ FROM uploaded_emails1, candidate_emails1
WHERE uploaded_emails1.from_ != 'test@email_domain.com'
AND uploaded_emails1.from_ != candidate_emails1.email
答案 2 :(得分:0)
通过使用NOT IN
子句或NOT EXISTS
子句,有两种方法可以做到这一点:
SELECT
from_
FROM uploaded_emails1
WHERE uploaded_emails1.from_ != 'test@email_domain.com'
AND NOT EXISTS (
SELECT *
FROM candidate_emails1
WHERE candidate_emails1.email = uploaded_emails1.from_
);
...或...
SELECT
from_
FROM uploaded_emails1
WHERE uploaded_emails1.from_ != 'test@email_domain.com'
AND uploaded_emails1.from_ NOT IN (
SELECT email
FROM candidate_emails1
);