Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'jfb_cashier_fb.pt.third_party_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
1是改数据库配置
2改sql语句
百度翻译这段话:
SELECT列表的表达式#2不在GROUP BY子句中,并且包含非聚合列“jfb_cashier_fb.pt.third_party_id”,该列在功能上不依赖于GROUP BY子句的列;这与sqlmode=onlyfull_groupby不兼容
意思就是third_party_id这个列在 group by 中出现了,在select中,就不要去写什么 sum
count max(third_party_id)这种了。直接写列名。同样,如果写了聚合函数的字段出现在select中,就不要在group by 后面出现了,不然也会报这种问题。
改sql的时候,该写聚合函数就写聚合函数,该在group by后加字段就加,看具体情况。
另外附加:
select @@global.sql_mode 查询是否设置有only_full_group_by
设置 sql_mode
set @@global.sql_mode='........,only_full_group_by' 设置这个模式。
- only_full_group_by mysql group full onlyonly_full_group_by mysql group only only_full_group_by sql_mode mysql group only_full_group_by mysql group full only_full_group_by docker mysql8问题 only_full_group_by only_full_group_by incompatible sql_mode group clause group only_full_group_by nonaggregated only_full_group_by nonaggregated incompatible only_full_group_by functionally incompatible only_full_group_by sql_mode版本 办法