一个技术宅的个人博客

报错 SELECT list is not in GROUP BY clause

[Err] 1055 – Expression #10 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘xxx’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

MySQL 5.7.x 默认是开启了 ONLY_FULL_GROUP_BY 我知道这样不规则,有隐患。
但问题是开发服上是没开的,之前项目的代码都是这么写的,不把本地处理一下,我几乎没法干活。不可能去把别人写的SQL全改了吧。

— 默认 SET @@GLOBAL.sql_mode=“ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”; — 去掉 ONLY_FULL_GROUP_BY 其它不变 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”;

改完了要在新打开的查寻窗口才有用,原来的没有效果的。

赞(10) 打赏
未经允许不得转载:孙健个人博客 » 报错 SELECT list is not in GROUP BY clause

评论 1

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏