nested exception is java.sql.SQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘t.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
sql报这个错是因为,sql语句进group by 查询时,有字段不在group by 导致报错.
修改一下mysql配置即可.
方案一: 临时修改
-- 通过该语句查询 可以发现结果存在 ONLY_FULL_GROUP_BY 选项
select @@global.sql_mode;
-- 进行修改即可
set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
方案二:
进入my.ini中进行配置,然后重启mysql即可
# 修改sql_mode配置
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION