• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trying to summarize a table

#1
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
proof that an old dog can learn new tricks
Reply

#2
@richb201,

Your sql statement looks good. Have you tried inserting just one record at a time?
Reply

#3
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.
proof that an old dog can learn new tricks
Reply

#4
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
proof that an old dog can learn new tricks
Reply

#5
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
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
@richb201,

The query was exactly the same except for a space being removed. How did you resolve the error?
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.