创建时间:2020-06-28 17:29:52
最近的项目用到mysql8.0,在用group by的时候会报错Error Code: 1055. Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘×××’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
查了下这是mysql5.7下mysql的model默认ONLY_FULL_GROUP_BY
含义 sql中select后面的字段必须出现在group by后面,或者被聚合函数包裹
解决方法直接修改my.cnfsql_mode =STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
2.在命令行运行set @@sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';