Mysql only_full_group_by 引起的错误
Posted yamboo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mysql only_full_group_by 引起的错误相关的知识,希望对你有一定的参考价值。
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘-._task.id‘ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
#查询当前的模式设置
SELECT @@sql_mode;
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
#设置mode[需要root有权限]
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 ‘;
#直接修改配置文件,然后重启
在my.cnf 里面设置
sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘
在sql_mode 中去掉only_full_group_by
以上是关于Mysql only_full_group_by 引起的错误的主要内容,如果未能解决你的问题,请参考以下文章
MySQL 5.7默认ONLY_FULL_GROUP_BY语义介绍
mysql only_full_group_by 的解决方案