MySQL:ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list c
2020-08-10 11:33
921 查看
mysql> select cno,avg(degree) from score where cno like '3-105' or cno like '3%%';
报错:ERROR 1140 (42000): In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'testmysql.score.cno'; this is incompatible with sql_mode=only_full_group_by
这个错误的中文翻译:
在不使用group by 子句的聚合查询中,Select列表中的第一个表达式包含了非聚合的列‘school.student.s_id’;当sql_mode为only_full_group_by时,是不能出现这种情况的。
错误信息里面说student.s_id 这一列是非聚合的,可能指的是没使用聚合函数,果不其然,当我在student.s_id前面加上max的时候,就可以正常执行了
也就是说,mysql的sql_mode是only_full_group_by的时候,在不使用group by 并且select后面出现聚集函数的话,那么所有被select的都应该是聚集函数,否则就会报错
解决:
需要重启mysql服务
编辑/etc/my.cnf文件,加入如下参数,重启mysql
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
相关文章推荐
- mysql查询出现In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated c
- mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg
- mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg
- ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
- ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
- ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains
- ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
- MySQL: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column '
- 解决MySql查询语句报Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre异常的问题
- mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题
- 解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
- SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP
- 【有效解决MySQL问题1】Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated....
- ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregate
- ERROR 1055 (42000): Expressionof SELECT list is not in GROUP BY clause sql_mode=only_full_group_by
- Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
- mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonag
- MYSQL:Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column
- MySQL: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sss
- mysql错误:Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated colum