【发布时间】:2016-07-12 21:42:41
【问题描述】:
尝试创建查询以选择在批处理超时时未通过电子邮件发送简报的用户。 mail_log 表从 3 个不同的邮件列表中捕获条目,并维护过去 4-5 周的日志 - 换句话说,每个订阅者应该有多个日志条目。
我想选择在发送时批处理超时时未收到电子邮件的所有订阅者。
mail_log
+--------+------------+-------------+------------+---------+
| log_id | send_date | location_id | mailing_id | list_id |
+--------+------------+-------------+------------+---------+
location_id is which mailing list
mailing_id is the specific newsletter
list_id is the subscriber's id in the mailing list
mail_list
+---------+-------+-------+-------+
| list_id | fname | lname | email |
+---------+-------+-------+-------+
我试过这个查询:
SELECT mail_list.*
FROM mail_list
LEFT JOIN mail_log ON mail_log.list_id = mail_list.list_id
WHERE mail_log.send_date = '2016-07-12'
AND mail_log.location_id = '2'
AND mail_log.list_id IS NULL`
查询返回 0 个结果,但成功的查询应该返回大约 700 个结果。
【问题讨论】:
-
是的,Dangers of Not In 的无耻广告机会
-
你还必须选择
mail_log.*-- -
将 WHERE 更改为 AND。将最后的 AND 更改为 WHERE
-
@Zak 为什么他需要选择它们?所有这些列都是
NULL。
标签: mysql