Mysql question about UPDATE
        Posted  
        
            by Beck
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Beck
        
        
        
        Published on 2010-05-18T13:56:59Z
        Indexed on 
            2010/05/18
            14:00 UTC
        
        
        Read the original article
        Hit count: 195
        
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. :)
© Stack Overflow or respective owner