Mysql question about UPDATE
- by Beck
UPDATE counter_reports
SET `counter`=`counter`+1,`date`=?
WHERE report_id IN(
(SELECT report_id FROM counter_reports WHERE report_name="emails_sent" AND `year`=1 ORDER BY report_id DESC LIMIT 1),
(SELECT report_id FROM counter_reports WHERE report_name="emails_sent" AND `month`=1 ORDER BY report_id DESC LIMIT 1),
(SELECT report_id FROM counter_reports WHERE report_name="emails_sent" AND `week`=1 ORDER BY report_id DESC LIMIT 1),
(SELECT report_id FROM counter_reports WHERE report_name="emails_sent" AND `day`=1 ORDER BY report_id DESC LIMIT 1)
)
Is there any alternative for such sql? I need to update(increment by 1) last counter reports for day,week,month and year.
If I'm adding manually, sql works fine, but with subqueries it fails to launch.
Thanks. :)