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. (五).JavaScript的函数

    1. 函数 1.1 函数基础简介 函数介绍 函数:具有特定功能的代码块 本质:一种对象数据类型 功能:1. 代码复用 2. 项目模块化 函数组成(两者必须同时存在): 1. 函数定义 2. 函数调用 ...

  2. 【原创】GmSSL Android库编译

    相关内容: GmSSL Linux编译 环境搭建 重要 用编译方法2编译出的库,集成到工程之后,发现报 incompatible target错误,各种找不到定义.32位和64位都不行. 如果你也遇到 ...

  3. 磊磊零基础打卡算法:day17 c++堆排序

    5.20 前言吐槽: 今天是5.20啦,但是作为单身修狗的我只能和代码过啦...继续加油算法打卡!!! 堆排序: 堆就是一棵完全二叉树 二叉堆是一种支持插入,删除,查询最值的数据结构.他其实是一棵满足 ...

  4. v-imgerror作用:当图片链接无效的时候,显示默认图片内容

    // 回顾自定义指令 // 作用: 自定义一些对DOM的操作快捷指令 // 前提: 指令就是用来操作DOM (v-if/v-show/v-for....) // 语法: Vue.directive(指 ...

  5. Leecode 3.无重复字符的最大字串长度(Java 暴力拆解)

    想法: 1.暴力解法,遇到重复字符就重新开辟空间,最后比较字串长度. 2.指针,但思路不太清晰   ----查看答案和思路,重新整理 滑动窗口:   1.设left,right用于下标值,length ...

  6. win服务项因各种原因出问题,删除注册表服务项

    win7系统,可以cmd–>sc delete 服务名称win10计算机\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 删除相关服务即 ...

  7. Android Studio Dolphin 稳定版正式发布

      作者 / Yuri Blaise, Product Manager, Android为了帮助开发者们更轻松地打造高质量应用,Android Studio 团队深入调研,为大家带来了最新稳定版 An ...

  8. 求pi

    参考自:https://www.zhihu.com/question/402311979 由 \[\frac{\pi^4}{90}={\textstyle \sum_{n=1}^{\infty }} ...

  9. react hooks(useState、useEffect、useRef详解)

    好巧不巧,工作了一年跳槽了,之前用的vue,现在用的react- 嗯!工作使人进步!现在开始学react吧! 切入正题- react hooks是React16.8.0之后出现的, 类组件存在的问题: ...

  10. What is UDS Service 0x10 - Diagnostic Session Control ?

    Why need the UDS Service 0x10? ECU在正常工作时会处于某一个会话模式下,上电后会自动进入默认会话模式,所以ECU启动后我们不需要输入0x10 01来进入该会话模式.EC ...