Mysql Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘xx‘
MySql执行分组sql报错:
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated
column 'db.tir1.display_name' which is not functionally dependent on columns in
GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
原因:使用GROUP BY 语句违背了sql_mode=only_full_group_by,该SQL是不合法的。使用group by分组查询的时候,在select列中查询的字段在group by中不存在,并且改字段没有在聚合函数里面。会报sql不合法。 mysql 5.7默认启用ONLY_FULL_GROUP_BY特性。
解决方法
- 在mysql的配置文件的最后强制设置sql_mode,把默认的ONLY_FULL_GROUP_BY去掉。
重新启动mysql后生效。 - 全局配置修改
查询:
select @@global.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'
退出生效。对于新建的立即生效。
最后还是建议大家合法编写SQL语句进行。除非是业务需要,不然不到万不得已千万不要擅自修改配置信息。
Mysql Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘xx‘的更多相关文章
- [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 ...
- 【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 ...
- 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 ...
- 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升级后出现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 ...
- Error Code: 1055.Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
环境:mysql-8.0.15-winx64 问题描述: Error querying database. Cause: java.sql.SQLSyntaxErrorException: Expre ...
- Expression #4 of SELECT list is not in GROUP BY clause and contains nonaggregated column
Error: javax.servlet.ServletException: java.sql.SQLSyntaxErrorException: Expression #4 of SELECT lis ...
- Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo.
安装了mysql5.7,用group by 查询时抛出如下异常: Expression # of SELECT list is not in GROUP BY clause and contains ...
- Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
安装了mysql5.7.19后,执行语句中只要含有group by 就会报这个错 [Err] 1055 - Expression #1 of ORDER BY clause is not in GRO ...
随机推荐
- 拉勾java核心类库--String类
String类 @author :magiclx 摘要:String类是用final进行修饰的,关于字符串的一个类,其中包含很多个方法 关键词:String,常量池,正则表达式,数组转化 正文: 参考 ...
- CAS无锁机制
1. 背景 传统Synchronized锁:悲观,如果没有获取到锁的情况下,会让当前线程变为阻塞的状态,释放CPU执行权,效率非常低. 乐观锁(自旋):本质上没有锁,没有死锁现象,而且效率比较高,不会 ...
- SXSSFWorkbook 表格内换行
起因 导出的excel需要在表格内换行,但搜索到的方法都实现不了我的需求,经同事搜查得知,这是POI的一个bug,已经在17年八月后被解决. 生成方式 pom依赖 <dependency> ...
- 谷歌翻译不能用解决办法(谷歌翻译关闭后,如何继续使用Chrome浏览器的翻译功能?)
1.查找 IP 虽然谷歌不再提供 translate.google.cn 网页版的服务了,但谷歌翻译的 API 服务还在. 只需要通过 hosts 重定向至国内服务器,即可恢复使用. 1.Ping ...
- 删除Mac版word上方的Mathtype
原因 Mac升级到macOS Catalina v10.15.3发现mathtype用不了, Mathtype官网说目前暂时不支持这个版本的系统. 现在尴尬的是, mathtype删除了, 但一不小心 ...
- 9. PEP8规范
1. 每一级缩进4个空格 2. 续行时缩进要比正常行多缩进, 要能明显看出是续行的 3. 每一行最多79个字符 4. 函数和类定义时在前后加2个空行, 类内接口在定义时, 前后加1个空行 5. 二元运 ...
- 《MySQL是怎样运行的》第五章小结
- 【chatQA】nvm包版本管理
如何使用nvm来管理不同版本的 Node.js,然后使用不同的 Node.js 版本来运行不同版本的 React 应用? 要使用 nvm 来管理不同版本的 Node.js,可以按照以下步骤进行操作: ...
- Servlet和Maven项目
Servlet执行流程 通过默认端口号访问到Tomcat服务器 通过类名访问到对应的项目 通过自定义的相应路径,访问到注释中的同名路径 即为执行流程 相应的Servlet对象由Tomcat服务器创建, ...
- ElasticSearch 实现分词全文检索 - id、ids、prefix、fuzzy、wildcard、range、regexp 查询
目录 ElasticSearch 实现分词全文检索 - 概述 ElasticSearch 实现分词全文检索 - ES.Kibana.IK安装 ElasticSearch 实现分词全文检索 - Rest ...