在没有 GROUP BY 的聚合查询中,SELECT 列表的表达式 #1 包含非聚合列 'c

172 阅读1分钟

这个问题查看了无数的教程,并没有得到很好地解决,在此记录一下,以后等会的知识多了,看能不能处理。 数据库查询时,出现以下错误: Caused by: java.sql.SQLSyntaxErrorException: In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'unicom_edu.sys_u.sys_name'; this is incompatible with sql_mode=only_full_group_by

查了好多个教程: 有修改sql_mode的 select version(), @@sql_mode; SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

有这样改my.cnf配置的 sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

还有

image.png

难搞。