1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated colum

Posted sunwk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated colum相关的知识,希望对你有一定的参考价值。

mysql5.7执行sql语句报错:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column ‘football.order.id‘; this is incompatible with sql_mode=only_full_group_by

找了好久找到可行的办法分享下



1.方法1,需要重启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"

技术图片



2.方法2,不需要重启mysql服务





可以看到模式为only_full_group_by

mysql>show variables like ‘%sql_mode‘;



mysql> show session variables like ‘%sql_mode%‘;

mysql> show global variables like ‘%sql_mode%‘;





使当前会话失效

mysql> set global sql_mode=‘‘;

mysql> set session sql_mode=‘‘;

以上是关于1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated colum的主要内容,如果未能解决你的问题,请参考以下文章

mysql:In aggregated query without GROUP BY, expression #1 of SELECT list contains...........

mysql:In aggregated query without GROUP BY, expression #1 of SELECT list contains...........

mysql查询出现In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated c

[Elasticsearch] 过滤查询以及聚合(Filtering Queries and Aggregations)

Elasticsearch Index API & Aggregations API & Query DSL

GOOGLE DATA STUDIO BIG QUERY count distinct aggregation is NOT WORKING