MySQL的内部联接对面 [英] mysql opposite of inner join
问题描述
我想使用我的数据库通过电子邮件与我的用户联系.我想确保我不会不小心联系同一位用户两次.为此,我有一个表来跟踪与谁联系以及何时联系.
I want to contact my users via email using my database. I want to make sure that I don't accidentally contact the same user twice. For that, I have a table that tracks who got contacted and when.
当我执行MYSQL查询时,我想从email
表中选择电子邮件,并确保contacted
表中没有这些条目.
When I do my MYSQL query I want to select emails from the the email
table and make sure none of those entries exists in the contacted
table.
要在句子中添加短语:如果电子邮件表"中没有电子邮件,请从电子邮件表"中选择电子邮件
To phrase it in a sentence: select email from Email_Table if they are not in Contacted_Table
也许有一种完全不同的方法.我愿意接受所有建议:)谢谢:)
Perhaps there is a completely different approach. I am open to all suggestions :)Thank you :)
推荐答案
select email
from Email_Table t1
where not exists (select email
from Contacted_table t2
where t1.email = t2.email)
OR
select email
from Email_Table t1
where email not in (select email
from Contacted_table)
这篇关于MySQL的内部联接对面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!