mysql执行group by时遇到下面提示:
SELECT list is not in GROUP BY clause and contains nonaggregated column 'crm.b.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:在sql执行时,出现该原因:就是输出的结果是叫target list,就是select后面跟着的字段;还有一个地方group by column,就是 group by后面跟着的字段。由于开启ONLY_FULL_GROUP_BY的设置,所以如果一个字段没有在target list 和group by字段中同时出现,或者是聚合函数的值的话,那么这条sql查询是被mysql认为非法的,会报错误
执行以下sql:
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'; mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
原文链接:https://blog.csdn.net/zhoupenghui168/article/details/91801102
标签:full,group,NO,mysql,incompatible,ZERO,mode,sql From: https://www.cnblogs.com/wjs2019/p/18348560