mysql 与内连接相反
我想使用我的数据库通过电子邮件联系我的用户。我想确保我不会意外地两次联系同一用户。为此,我有一个表格来跟踪谁被联系以及何时被联系。
当我执行 MYSQL 查询时,我想从 email
表中选择电子邮件,并确保 contacted
表中不存在这些条目。
用一句话来表达:如果电子邮件不在 Contacted_Table 中,则从 Email_Table 中选择电子邮件
也许有一种完全不同的方法。我愿意接受所有建议:)谢谢:)
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.
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 :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个
Try this
或
OR
如果您尝试像这样进行左连接:
您将得到类似的结果:
您的目标是获取那些在
contacted
表中没有匹配项的记录,因此您的查询将是:If you try to do a left join like this:
You will get a similar result:
Your goal is to get those record which do not have a match in the
contacted
table, so your query would be:删除电子邮件_表
FROM email_table INNER JOIN 联系
ON email_table.email_id = contacted.email_id;
DELETE email_table
FROM email_table INNER JOIN contacted
ON email_table.email_id = contacted.email_id;