I am trying to copy row(s) from a table using MySQL query but its showing error like
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order,creater_id,created_date,updated_id,updated_date)
SELECT activ' at line 1
function copyActivityByActivityId($activity_details_option, $time_hour, $time_min, $distance, $order, $creater_id, $updated_id, $aid) {
$this->load->database();
$this->load->helper('date');
$datestring = "%Y-%m-%d: %H:%i:%s";
$time = time();
$today = mdate($datestring, $time);
$this->db->trans_begin();
$this->db->query("INSERT INTO calorie_activity (activity_name,mets,parent_id,distance_unit,cals,activity_details_option,time_hour,time_min,distance,order,creater_id,created_date,updated_id,updated_date)
SELECT activity_name,mets,parent_id,distance_unit,cals,'$activity_details_option',$time_hour,$time_min,'$distance','$order','$creater_id','$today','$updated_id','$today' FROM calorie_activity where id='".$aid ."'");
if ($this->db->trans_status() === FALSE) {
$this->db->trans_rollback();
return false;
} else {
$this->db->trans_commit();
return true;
}
}
why am getting syntax error? any help