mysql 开启only_full_group_by模式,该模式下使用mysql老版本的写法取group by分组数据会报错,报错如下:
`Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘wenming-bj-mtg.comments.organization_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

时间: 0s`
mysql 使用group by报错 sql_mode=only_full_group_by

ONLY_FULL_GROUP_BY这个配置启用的是 “严格ANSIsql 规则”,严格ANSI sql 规则要求在group by的时候,没有聚合的列,在group by的时候,必须全部包含在group by 的字段中。

在不关闭ONLY_FULL_GROUP_BY模式的情况下,将没有使用聚合函数的列,接在需要group by分组的字段后面,sql如下:

SELECT obj_id, area_id, organization_id, stars FROMcommentsWHEREarea_3= 2424 ANDtype= 2 ANDenabled= 1 ANDcreated_at>= '2020-05-02 00:00:00' ANDcreated_at<= '2020-07-22 16:00:00' GROUP BY obj_id,organization_id,area_id,stars

mysql 使用group by报错 sql_mode=only_full_group_by
这样就可以了,如果对您有帮助,点个????哈。

相关文章:

  • 2021-08-06
  • 2021-07-12
  • 2021-12-17
  • 2021-04-04
  • 2021-07-24
  • 2021-09-02
猜你喜欢
  • 2018-07-26
  • 2021-12-24
  • 2021-10-02
  • 2021-10-06
  • 2021-12-05
  • 2018-06-11
  • 2021-04-17
相关资源
相似解决方案