MySQL的内部联接对面 [英] mysql opposite of inner join

查看:54
本文介绍了MySQL的内部联接对面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用我的数据库通过电子邮件与我的用户联系.我想确保我不会不小心联系同一位用户两次.为此,我有一个表来跟踪与谁联系以及何时联系.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆