MySQL 报错:#1 of ORDER BY clause is not in GROUP BY sql_mode=only_full_group_by
程序员文章站
2023-12-28 14:47:16
...
MySQL 操作时,经常报如下错误:
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
一、错误原因
这个错误发生在mysql 5.7 版本及以上版本会出现的问题:
mysql 5.7版本默认的sql配置是:sql_mode=“ONLY_FULL_GROUP_BY”,这个配置严格执行了"SQL92标准"。
很多从5.6升级到5.7时,为了语法兼容,大部分都会选择调整sql_mode,使其保持跟5.6一致,为了尽量兼容程序。
解决方法
1、修改mysql配置 my.cnf(windows版本是 my.ini),增加一下配置:
sql_mode='NO_ENGINE_SUBSTITUTION
2、SQL语句修改
1)先执行sql,查看sql_mode
SELECT @@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
2)修改sql_mode,包括已有库和新建库,具体如下:
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';
SET sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
推荐阅读
-
MySQL 报错:#1 of ORDER BY clause is not in GROUP BY sql_mode=only_full_group_by
-
mysql 报错 this is incompatible with sql_mode=only_full_group_by
-
Mysql数据库报错:select list is not in group by clause and contains .....sql_mode=only_full_group_by问题
-
mysql only_full_group_by以及其他关于sql_mode原因报错详细解决方案
-
MYSQL8.0 排序查询报错 this is incompatible with sql_mode=only_full_group_by
-
MySQL5.7版本的only_full_group_by及关于sql_mode报错详细解决方案
-
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题 MySQL
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
-
mysql 使用group by报错 sql_mode=only_full_group_by 在navicat中修改session 中的sql_mode
-
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.