gpt4 book ai didi

mysql - MySQL版本升级时GROUP BY无效

转载 作者:行者123 更新时间:2023-11-29 18:16:08 28 4
gpt4 key购买 nike

当我将 ubuntu 从 15.10 升级到 16.04 时,我的 yii 项目出现此错误:

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'v4master.A.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by. The SQL statement executed was:

sql代码如下:

 $sql = "SELECT A.*,B.`type_name` FROM `".$this->tbl_auth_user_items."` A 
INNER JOIN `".$this->tbl_auth_context_types."` B ON A.`type_id` = B.`type_id`
WHERE A.`user_id` = '".$user_id."' GROUP BY A.`type_id`, A.`type_value` ORDER BY A.`type_id` DESC";
return $this->_db->createCommand($sql)->queryAll();

最佳答案

在 Mysql 上运行此查询;

set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

关于mysql - MySQL版本升级时GROUP BY无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47010581/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com