SELECT 列表的表达式 #1 不在 GROUP BY 子句中并且包含非聚合列。仅在共享主机 cPanel 中出现错误

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column. Getting error only in Shared Hosting cPanel

我正在使用 Codeigniter 3 开发一个项目。一切都很顺利,但是当我将我的项目上传到共享主机 cPanel 时。我收到这个错误。

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

问题仅出现在 cPanel 中。我尝试在共享主机的 phpmyadmin 中编辑变量。 (尝试编辑 sql_mode 并删除 ONLY_FULL_GROUP_BY),但出现权限错误。

#1227 - Access denied, You need (at least one of) the SUPER privilge(s) for this operation.

我被卡住并搜索了类似的问题,但这没有帮助。知道如何消除这些错误。

我的代码。

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();
        }

您尝试过 ANY_VALUE

在您的查询中,您按 class 分组,但在 select 中有 id ,created_at 像这样尝试

$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
            ')