thisis incompatible with sql_mode=only_full_group
错误代码: 1055
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.a.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
执行一个SQL报错。在mariadb执行正常。在mysql5.7.17中发现有问题。
原因:
看一下group by的语法:
select 选取分组中的列+聚合函数 from 表名称 group by 分组的列
从语法格式来看,是先有分组,再确定检索的列,检索的列只能在参加分组的列中选。
我当前Mysql版本5.7.17,
再看一下ONLY_FULL_GROUP_BY的意思是:对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP BY中出现,那么这个SQL是不合法的,因为列不在GROUP BY从句中,也就是说查出来的列必须在group by后面出现否则就会报错,或者这个字段出现在聚合函数里面。
查看mysql版本命令:select version();
查看sql_model参数命令:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.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,
解决方法:
1.只选择出现在group by后面的列,或者给列增加聚合函数;(不推荐)
2.命令行输入:
set @@GLOBAL.sql_mode='';
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';
默认关掉ONLY_FULL_GROUP_BY!
这个时候 在用工具select 一下
SELECT @@sql_mode;
SELECT @@GLOBAL.sql_mode;
发现已经不存在ONLY_FULL_GROUP_BY ,感觉已经OK。但是如果你重启Mysql服务的话,发现ONLY_FULL_GROUP_BY还是会存在的
想要彻底解决这个问题 就得去改my.ini 配置(如果你们mysql 没有这个文件,就把my-default.ini 改成my.ini,我这个版本就是没有my.ini配置问题)
在 [mysqld]和[mysql]下添加
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';
https://www.cnblogs.com/jim2016/p/6322703.html
转载于:https://blog.51cto.com/woniu123/2108583
thisis incompatible with sql_mode=only_full_group相关推荐
- incompatible with sql_mode=only_full_group_by
使用mysql 5.7.11-debug Homebrew时报错 错误信息如下: 26 Mar 2016 09:35:23,432 ERROR org.hibernate.engine.jdbc.sp ...
- this is incompatible with sql_mode=only_full_group_by
mysql 执行select语句里面包含group by 分组函数 但是出现下面的问题 Caused by: java.sql.SQLSyntaxErrorException: Expression ...
- mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by
在mysql 工具 搜索或者插入数据时报下面错误: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause ...
- mysql查询报错: ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by
前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. 我的情况 : Mysql 5.7.21 版本运行sql 报错如题,同样的 sql 直接本地运行不报错 ...
- 错误:this is incompatible with sql_mode=only_full_group_by
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'H5APP_WORK ...
- mysql5.7 gruop by报错this is incompatible with sql_mode=only_full_group_by
解析:在mysql 工具 搜索或者插入数据时报下面错误: ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY cla ...
- MySQL报错this is incompatible with sql_mode=only_full_group_by
1.报错信息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP ...
- columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 版本mysql8.0
问题如下: ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonagg ...
- mysql升级到5.7版本后,运行程序报错this is incompatible with sql_mode=only_full_group_by
升级mysql后,运行程序报错 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains ...
最新文章
- 机器学习中如何处理缺失数据(NAN和Ifo)?
- 了解 Boost Filesystem Library文件系统
- WINDOWS下对音频的处理过程(转)
- pcie ep 应该支持哪种interrupt_双盘位NAS支持PCI扩展可以做什么?QNAP QM2-2S10G1T应用场景讨论...
- 解决vue中路由跳转同一个路径报错
- 机器学习核心算法之——贝叶斯方法
- 王道考研学习笔记IP数据报格式IP数据报分片(超详细)
- TypeScript入门教程 之 for ... of 与 for ... in
- 帧间差分法_OpenCV_详解
- React vs Angular,哪种学习成本更低?
- RCNN,fast R-CNN,faster R-CNN
- 超英文邮件50%!Flink 中文邮件列表必须有姓名
- 【最全解决方案】WPS软件复制PDF后粘贴到Word格式混乱,如图,如何解决?
- 什么是集合?数组与集合的区别
- c++ PDFium pdf转为图片
- 超长内容自动显示省略号
- c语言vc是什么意思,这个VC语句是什么意思
- Python 从函数 def 到类 Class
- KK 给年轻人的99条建议
- 数学小故事之拉格朗日的世界