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特性。
解决方法

  1. 在mysql的配置文件的最后强制设置sql_mode,把默认的ONLY_FULL_GROUP_BY去掉。
    重新启动mysql后生效。
  2. 全局配置修改
    查询:
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‘的更多相关文章

  1. [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 ...

  2. 【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 ...

  3. 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 ...

  4. 记录一次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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. 2020/03/24 HTML基础复习笔记

    2020-03-24 15:49:30 下午好! 这是我开通博客的第二天也是在钉钉上网课的又一天,为了应对考试现在复习到了HTML基础知识,本打算用VS敲想了想还是用了XMind(真的好用!!!)文件 ...

  2. 让 rtb 不显示 横纵 滚动条的方法

    让 rtb 不显示 横纵 滚动条的方法: a.设置属性: tb.ScrollBars=None; b.设置属性:rtb.WordWarp=False; c. 添加事件代码: rtb.ContentsR ...

  3. 深入理解css 笔记(6)

    网格布局:flexbox 彻底改变了网页布局方式,但这只是开始.它还有一个大哥:另一个称作网格布局模块的新规范.这两个规范提供了一种前所未有的全功能布局引擎.跟 flexbox 类似,网格布局也是作用 ...

  4. Scrapy框架报错:Ignoring non-200 response

    1.当爬取页面状态码是异常状态码,但response是正常的时候,正常情况Scrapy框架会判断状态码,如果不是正常状态码会停止后续操作 解决方案: 在meta"handle_httpsta ...

  5. Tensorflow learning notebook

    How does tensorflow work 原著blog https://jacobbuckman.com/#posts

  6. Boost.Asio C++ 网络编程

    在线电子书:https://mmoaay.gitbooks.io/boost-asio-cpp-network-programming-chinese/content/Chapter1.html

  7. 使用php将字典格式的字符串转为array

    例: 原字符串为 $a = '{"errcode":0,"errmsg":"ok","msgid":1472671765 ...

  8. Javaweb基础复习------Filter相关应用+登录验证案例的使用

    Filter(过滤器) 基本步骤: 1.定义类,实现Filter接口,并重写其所有方法 2.配置Filter拦截资源的路径,在类上定义2 WebFilter注解(WebFilter配置的路径,是拦截资 ...

  9. 一个由public关键字引发的bug

    先来看一段代码: @Service @Slf4j public class AopTestService { public String name = "真的吗"; @Retrya ...

  10. epub文件如何查看

    http://epub-reader.online/# 你可以用在线的epub阅读器查看. 你可以使用本地的epub阅读器查看.如neatReader,wps. 你可以将epub转换成pdf,然后查看 ...