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. LNMP架构的演变

    LNMP 演变 工作原理 linux + nginx + mariadb + php 工作原理: 首先,浏览器发送http request请求到服务器(Nginx),服务器响应并处理web请求, 将一 ...

  2. cerebro简单使用 , ES界面化工具 , 网页查看 , 操作索引

    下载安装 下载地址 https://github.com/lmenezes/cerebro/releases 解压即用 , 目录中不能有空格和中文 需要jdk11及以上(实际我本机只有jdk8也能用) ...

  3. white-space: pre-line;的坑

    html模版解析换行 这是字符串 跟标签设置white-space: pre-line: pre兼容ie8,pre-line不兼容ie 6-7 这行文字开头是没有空格的但是还是有很大的空格,代码方法截 ...

  4. tensorflow出现Failed to get convolution algorithm, cuDNN failed to initialize

    网上大多的教程是说tensorflow的版本过高,或者说cuda和cudnn的版本不对,需要降级,但这样会很麻烦!!! 以下值得推荐!!! 解决方法一:在代码前加上下面的代码 from tensorf ...

  5. scrapy.Request callback不执行

    1.在scrapy.Request方法里边加上参数dont_filter=True(去重) 2.增加是不是allowed_domains范围内的url 3.yield Request 改为yield ...

  6. 记录Nginx配置

    1 # Proxy to the Airsonic server location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_hea ...

  7. Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on

    解决错误 Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test ...

  8. Java笔记第二弹

    List常用集合子类的特点 ArrayList底层数据结构是数组 查询快,增删慢 LinkedList底层数据结构是链表 查询慢,增删快 练习: //ArrayList实现 import java.u ...

  9. Android笔记--在活动之间传递消息

    显式Intent和隐式Intent Intent--各个组件信息沟通的桥梁 组成部分: 显式Intent:--精确匹配 具体实现: 1.在Intent的构造函数中指定 2.调用意图对象的setClas ...

  10. Spring--事务角色+事务属性

    事务管理员 发起事务方,在Spring中通常指代业务层开启事务的方法 也就是相当于这个: 事务协调员 加入事务方,在Spring中通常指代数据层方法,也可以是业务层方法 也就是相当于这个: 事务相关配 ...