I'm working on a project in Codeigniter 3. Everything was going fine but when i uploaded my project to shared hosting cPanel. I got this error.
Error Number: 42000/1055
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'siyabdev_smart_school.classes.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
The issues appears only in the cPanel. I tried editing variables inside phpmyadmin of shared hosting. (tried editing sql_mode and removing the ONLY_FULL_GROUP_BY
), but i got a permission error.
#1227 - Access denied, You need (at least one of) the SUPER privilge(s) for this operation.
I'm stuck and searched for the similar questions but that did not help. Any idea how to get rid of these errors.
My Code.
public function get_classes () {
$q = $this->db->select('
`classes`.`id`,
`classes`.`class`,
GROUP_CONCAT(`sections`.`section`) AS sections,
`classes`.`created_at`
')
->join('classes', '`classes`.`id` = `class_sections`.`class_id`', 'inner')
->join('sections', '`sections`.`id` = `class_sections`.`section_id`', 'inner')
->group_by("`classes`.`class`")
->get('class_sections');
return $q->result();
}
Have you tried with ANY_VALUE
In your query you have group by class but in select there is id , created_at Try like this
$q = $this->db->select('
ANY_VALUE(`classes`.`id`) AS id,
`classes`.`class`,
GROUP_CONCAT(`sections`.`section`) AS sections,
ANY_VALUE(`classes`.`created_at`) AS created_at
')