I need to return only rows that are repeated lets say 30 times in my database. I added this COUNT function after SELECT but honestly have no idea what to do as a next step. Could someone advice me please?
$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'";
Do a GROUP BY
all selected rows. Use HAVING
to only return rows that appear at least 30 times.
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
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments