解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
前言:
借鉴网址:https://blog.csdn.net/fansili/article/details/78664267
原因:
MySQL 5.7.5和up实现了对功能依赖的检测。如果启用了only_full_group_by SQL模式(在默认情况下是这样),那么MySQL就会拒绝选择列表、条件或顺序列表引用的查询,这些查询将引用组中未命名的非聚合列,而不是在功能上依赖于它们。(在5.7.5之前,MySQL没有检测到功能依赖项,only_full_group_by在默认情况下是不启用的。关于前5.7.5行为的描述,请参阅MySQL 5.6参考手册。)
执行以下个命令,可以查看 sql_mode 的内容:
mysql> SHOW SESSION VARIABLES;
mysql> SHOW GLOBAL VARIABLES;
mysql> select @@sql_mode; 可见session和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 :使用这个就是使用和oracle一样的group 规则, select的列都要在group中,或者本身是聚合列(SUM,AVG,MAX,MIN) 才行,其实这个配置目前个人感觉和distinct差不多的,所以去掉就好
解决:
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 session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
解决大于5.7版本mysql的分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.的更多相关文章
- mysql分组报错Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
环境:Server version: 5.7.27-0 ubuntu 18.04.1 (Ubuntu) 执行分组语句:select * from pet group by owner;时报错: mys ...
- mysql升级后出现Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
安装了mysql5.7,用group by 查询时抛出如下异常: Expression #3 of SELECT list is not in GROUP BY clause and contains ...
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'blog.t_blog.addTime' which is not functi
sql报错: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT ...
- 记录一次mysql由5.6升级到5.7出现的异常---Expression #23 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'c.commentCount' which is not functionally dependent on columns in GROUP BY clause;
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expre ...
- 【mybatis】【mysql】mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
mybatis查询mysql,group by分组查询报错:Expression #1 of SELECT list is not in GROUP BY clause and contains no ...
- [mysql] Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'loser.tank_admin.login_ip' which is not functionally dependent on columns in GROUP BY clause; this is
执行SQL: SELECT login_name,login_ip,sex FROM tank_admin GROUP BY login_name ; 时抛出异常. Expression #2 of ...
- MYSQL报错:1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'rpa ...
- mysql问题解决SELECT list is not in GROUP BY clause and contains nonaggregated column
今天在Ubuntu下的部署项目,发现一些好好的列表页面发生 :Expression # of SELECT list is not in GROUP BY clause and contains no ...
- mysql 8.0下的SELECT list is not in GROUP BY clause and contains nonaggregated column
mysql的版本 mysql> select version();+-----------+| version() |+-----------+| 8.0.12 |+-----------+ 在 ...
随机推荐
- nodejs的一些基操
Nodejs 是基于 CHrome V8 引擎的 JaveScriptnpm: node 包管理器为我们提供了: nodejs 运行时,javascript 代码运行时的环境 提供了核心模块,具体会在 ...
- cf 1182 E - Product Oriented Recurrence
当时脑残了, 不会写矩阵快速幂中更改的系数, 其实把他扔到矩阵里同时递推就好了 #include<cstdio> #include<algorithm> #include< ...
- Codeforces.1029D.Isolation(DP 分块)
题目链接 \(Description\) 给定长为\(n\)的序列\(A_i\)和一个整数\(K\).把它划分成若干段,满足每段中恰好出现过一次的数的个数\(\leq K\).求方案数. \(K\le ...
- [LeetCode] 547. Friend Circles 朋友圈
There are N students in a class. Some of them are friends, while some are not. Their friendship is t ...
- java web开发入门十一(idea maven mybatis自动代码生成)基于intellig idea
6.idea maven mybatis逆向工程(代码生成器) 1.配置pom.xml 在plugins标签下添加mybatis-generator-maven-plugin <plugin&g ...
- 509道Java面试题解析:2020年最新Java面试题
<Java面试全解析>是我在 GitChat 发布的一门电子书,全书总共有 15 万字和 505 道 Java 面试题解析,目前来说应该是最实用和最全的 Java 面试题解析了. 我本人是 ...
- android 自定义gridview(导航)
最近又重新做回安卓,做了个小项目.下绝心使用android studio,通过这一回实战,终于用上了.综合了前人的经验,搞了个自己满意的导航界面,用的是gridview. 代码: package co ...
- leetcode 903. DI序列的有效排列
题目描述: 我们给出 S,一个源于 {'D', 'I'} 的长度为 n 的字符串 .(这些字母代表 “减少” 和 “增加”.)有效排列 是对整数 {0, 1, ..., n} 的一个排列 P[0], ...
- iOS依赖库管理工具之CocoaPods
CocoaPods 是开发 OS X 和 iOS 应用程序的一个第三方库的依赖管理工具.利用 CocoaPods,可以定义自己的依赖关系库 (称作 pods),并且随着时间的变化,在整个开发环境中对第 ...
- CentOS7 Hbase 安装(完全分布式)
安装前准备 hadoop安装 zookeeper安装 安装步骤 1.下载 $ wget http://mirror.bit.edu.cn/apache/hbase/2.0.5/hbase-2.0.5- ...