trying to summarize a table - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: trying to summarize a table (/showthread.php?tid=72485) |
trying to summarize a table - richb201 - 12-27-2018 I have an sql line that is failing. $sql='INSERT INTO weekly_summary_activities (email,campaign, admin_email, type, year, week, business_comp, project, activity, hours) SELECT email, campaign, admin_email, type, year, week, business_comp, project, activity, SUM(hours) FROM activity_log GROUP BY email, campaign, project, business_comp, activity'; $query=$this->db->query($sql); weekly_summary_activities has an autoinc field called id. What do I do about that? Of course I don't have the id field in my query. when I run this is phpmyadmin I get: #1467 - Failed to read auto-increment value from storage engine RE: trying to summarize a table - php_rocs - 12-27-2018 @richb201, Your sql statement looks good. Have you tried inserting just one record at a time? RE: trying to summarize a table - richb201 - 12-27-2018 I am not sure how to do that. I am on vacation for the next week and will look at it again when I get back. RE: trying to summarize a table - richb201 - 12-27-2018 I solved this. I used the following: INSERT INTO weekly_summary_activities (email,campaign, admin_email, type, year, week, business_comp, project, activity, hours) SELECT email, campaign, admin_email, type, year, week, business_comp, project, activity, SUM(hours) FROM activity_log GROUP BY email, campaign, project, business_comp, activity RE: trying to summarize a table - InsiteFX - 12-28-2018 Your error has something to do with your auto_increment value. If you read the error it states this. #1467 - Failed to read auto-increment value from storage engine RE: trying to summarize a table - php_rocs - 12-28-2018 @richb201, The query was exactly the same except for a space being removed. How did you resolve the error? |