mysql only_full_group_by

发布时间 2023-07-04 21:13:04作者: HelloLLLLL
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' 设置这个模式。