MySQL:仅从一个表中选择电子邮件,如果不在另一个表中? [英] MySQL: select emails from one table only if not in another table?

查看:55
本文介绍了MySQL:仅从一个表中选择电子邮件,如果不在另一个表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将建立一个名为donotemail的表,该表将包含要求从我们的电子邮件列表中删除的人员的电子邮件地址.我还有另一个表,名为用户",带有一个电子邮件列.仅当电子邮件地址不在donotemail表中时,如何才能选择所有来自用户的电子邮件?

I am going to build a table called donotemail that will contain the email addresses of people who ask to be removed from our email list. I have another table called users with an email column. How can I select all the emails from users but only if the email address is not in the donotemail table?

谢谢!

推荐答案

尝试

SELECT Email.address
FROM Email LEFT OUTER JOIN DoNotMail on Email.address = DoNotMail.address
WHERE DoNotMail.address is null

它避免了子查询.

这篇关于MySQL:仅从一个表中选择电子邮件,如果不在另一个表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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