报错:
java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'example.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:
这个错误是由于在启用了 sql_mode=only_full_group_by
的 MySQL 数据库中执行包含 GROUP BY
的查询导致的(MySQL 5.7.5 及更高版本默认启用此模式)。
解决:
在my.ini文件中最后加上
[mysqld]
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION