我只需要返回数据库中重复了30次的行。我在SELECT之后添加了这个COUNT函数,但老实说,我不知道下一步该怎么做。有人能给我建议吗?
$variable = "SELECT COUNT(mail.h_datetime, sent.f_mail_subject, sent.f_mail_content)"
."FROM mail"
."INNER JOIN sent ON mail.h_id = sent.e_mail_templates_id"
."WHERE f_template_type = 'newsletter'";
对所有选定行执行GROUP BY
。使用HAVING
仅返回至少出现30次的行。
SELECT mail.h_datetime, sent.f_mail_subject, sent.f_mail_content
FROM mail
INNER JOIN sent ON mail.h_id = sent.e_mail_templates_id
WHERE f_template_type = 'newsletter'
GROUP BY mail.h_datetime, sent.f_mail_subject, sent.f_mail_content
HAVING COUNT(*) >= 30