Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'prosper-dev.itemBaseInfo.item_picture' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
时间: 2023-07-18 17:25:45 浏览: 56
这个错误是由于 SQL 的执行模式中启用了 only_full_group_by 模式,导致在 GROUP BY 语句中的非聚合字段必须要在 SELECT 语句中显示出来。也就是说,如果你在 GROUP BY 语句中指定了某个字段,那么 SELECT 语句中也必须要包含这个字段。
为了解决这个错误,你可以在 MySQL 配置文件中将 sql_mode 改成非 only_full_group_by 模式,或者在 SELECT 语句中将所有非聚合字段都列出来。另外,你也可以使用聚合函数来简化 SELECT 语句,例如使用 MAX 函数来获取某个字段的最大值,这样就可以避免了这个错误。
相关问题
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
引用\[1\]、\[2\]和\[3\]都是关于MySQL报错的信息,其中提到了"Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column"的错误。这个错误是由于在使用GROUP BY子句进行分组查询时,SELECT列表中的某些列没有在GROUP BY子句中出现,并且这些列也没有被聚合函数包含,导致不兼容的错误。这个错误通常是由于MySQL的sql_mode设置为only_full_group_by引起的。解决这个错误的方法是要么将SELECT列表中的列添加到GROUP BY子句中,要么将这些列用聚合函数进行处理,以确保查询的正确性。
#### 引用[.reference_title]
- *1* *3* [MySQL报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ...](https://blog.csdn.net/Saintmm/article/details/124491860)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v4^insert_chatgpt"}} ] [.reference_item]
- *2* [Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre](https://blog.csdn.net/weixin_44051060/article/details/105602832)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v4^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column
Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column的错误是由于MySQL数据库的ONLY_FULL_GROUP_BY SQL模式导致的。在这个模式下,如果select语句中的查询列没有在group by语句中出现,就会报错。解决这个问题的方法是可以使用以下命令查看当前的SQL模式:select @@sql_mode; 或者 select @@global.sql_mode; 如果模式中包含only_full_group_by,则需要修改SQL模式来解决这个问题。