MySQL查询的时候出现 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre报错
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre …后面一大堆
出错就是这样
我们可以在网上看到很多解释
MySQL 5.7.5及以上功能依赖检测功能。如果启用了ONLY_FULL_GROUP_BY
SQL模式(默认情况下),MySQL将拒绝选择列表,HAVING条件或ORDER BY列表的查询引用在GROUP
BY子句中既未命名的非集合列,也不在功能上依赖于它们。(5.7.5之前,MySQL没有检测到功能依赖关系,默认情况下不启用ONLY_FULL_GROUP_BY。
大概的意思是你现在的MySQL版本高于5.7.5,因此MySQL多了一个依赖检测功能,导致了这个报错
如果之前用得好好的,现在环境换了之后报错,那就是因为之前用的是5.7.5以前的MySQL,现在的版本是5.7.5以后的
大多数解答都是这样的:
在查询里面输入
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,导致报错,我们要把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';
有些人到这里原本就结束了
但是
如果你的MySQL重启之后,你再重新查询,ONLY_FULL_GROUP_BY依然还是在,并没有删除成功
这时候你就要到MySQL的配置文件里面改了(window环境下是my.ini文件,Linux环境下是my.cnf)
我们这里写Linux环境下的解决办法:
如果Linux系统里面找不到my.cnf,可以用这个命令
find / -name my.cnf
这时候会出现
/usr/local/mysql/storage/ndb/test/crund/config_samples/my.cnf
/usr/local/mysql/rapid/plugin/group_replication/tests/mtr/my.cnf
/usr/local/mysql/mysql-test/suite/rpl_ndb/my.cnf
/usr/local/mysql/mysql-test/suite/rpl/my.cnf
/usr/local/mysql/mysql-test/suite/rpl/extension/bhs/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_memcache/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_big/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_binlog/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_team/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_ddl/my.cnf
/usr/local/mysql/mysql-test/suite/ndbcluster/my.cnf
/usr/local/mysql/mysql-test/suite/ndb/my.cnf
/usr/local/mysql/mysql-test/suite/ndb_rpl/my.cnf
/usr/local/mysql/mysql-test/suite/federated/my.cnf
/etc/my.cnf
我们进入最后那个文件
然后在
[mysqld]
下面找个地方写
sql-mode="NO_UNSIGNED_SUBTRACTION,NO_ENGINE_SUBSTITUTION"
保存重启MySQL,就解决了!!!
Linux环境下开启与关闭MySQL
MySQL查询的时候出现 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre报错相关推荐
- mySql中Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题
报错信息 Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'a.id' ...
- mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题
报错如下: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sss. ...
- MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”解决方法
解决MySQL5.7版本之后使用GROUP BY语句时报错 问题原因 解决方法 今天使用mysql简单的一句分组查询语句(GROUP BY)报错了. mysql> SELECT * FROM t ...
- 遇见 mysql Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre 问题
这是因为mysql5.7及以上版本的mysql中,对于 group by 的这种聚合操作,如果在select 中的列, 没有在group by 中出现,那么这个SQL是不合法的,因为列不在group ...
- mysql报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
原因: https://blog.csdn.net/fansili/article/details/78664267 解决办法: 1:查看mysql配置文件位置 [root@localhost ~]# ...
- 【阿里云 Linux 服务器】mysql 遇到以下问题Expression #1 of SELECT list is not in GROUP BY clause and contains nonag
报错信息如下: Caused by: java.sql.SQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY ...
- MySQL Expression 2 of SELECT list is not in GROUP BY clause and contains nonaggregated column yous
MySQL:Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'yous ...
- mysql 报错解决思考Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column
mysql报错: [Err] 1055 - Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggrega ...
- Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
场景 安装了mysql5.7,用group by 查询时抛出如下异常: Expression #1 of SELECT list is not in GROUP BY clause and conta ...
最新文章
- 仅需6步,教你轻易撕掉app开发框架的神秘面纱(2):MVP比MVC更好吗
- vrish 删除虚机_使用Kvm命令集管理虚拟机
- Yii2的MVC新特性
- Wiener Filter维纳滤波器halcon算子,持续更新
- 三个彩灯循环点亮程序_近百组彩灯点亮江畔,义渡灯会正式亮灯啦
- 智能灯控制页面用HTML编写,一种基于STM32的智能灯控制系统的制作方法
- 测试有道:微软测试技术心得 1
- PayPal支付开发
- WIN10 WIFI热点 手机连接显示无网络连接问题解决
- 个人博客百度统计中恶意刷无关关键词解决方案
- teredo 未能解析服务器名,关于Teredo 参数无法进行限定,服务器连接已阻止的各种解决办法...
- 前端vs图片 3 jpg、png、gif 图片老三样系统总结
- tree traversal (树的遍历) - inorder traversal (中序遍历)
- coding码市管理项目
- arcgis 做凹凸起伏的分类图
- nginx如何解析html响应,在nginx中,如何返回http 500返回码并包含响应客户端的响应体...
- dcmtk读取dcm文件中Tag值
- python往npy写入数据_操作python实现npy格式文件转换为txt文件
- css p段落首行缩进两个字符
- CUDA:两种自适应图像去噪技术KNN和NLM的实例