MySQL 严格模式引起的问题

MySQL 大约 640 字

错误信息

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre

SQL MODE

select @@sql_mode;

select @@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

  • 方法一:SQL中修改(重启后失效)
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’;
  • 方法二:在my.inimy.cnf中的[mysqld]下配置(需重启)
    sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
阅读 550 · 发布于 2019-04-07

————        END        ————

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批