我有一个邮件收件人表,通过many2many表(recipients_mails)链接到邮件表。每次发送邮件时,我都会在many2many表中添加一行。
我需要知道哪些收件人没有收到ID为n的电子邮件。 3.
这就是桌子的雕刻方式:
Recipients
recipient_id, email
Recipients_mails
recipient_fk, mail_fk
Mails
mail_id, content etc.
非常感谢
答案 0 :(得分:1)
SELECT *
FROM recipients
WHERE NOT EXISTS
(
SELECT NULL
FROM recipients_mails
WHERE (recipient_fk, mail_fk) = (recipient_id, 3)
)