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
它避免了子查询.