前言:

  借鉴网址: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.的更多相关文章

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

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

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

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

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

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

  9. mysql 8.0下的SELECT list is not in GROUP BY clause and contains nonaggregated column

    mysql的版本 mysql> select version();+-----------+| version() |+-----------+| 8.0.12 |+-----------+ 在 ...

随机推荐

  1. 【电脑】分屏显示输入信号超出范围调整为XXXXXXX

    选提示的那个范围就OK了. 注意:1.修改的是外界显示器,不是主显示器/笔记本.     2.修改外接显示器,不影响主显示器/笔记本

  2. 部署ComsenzDiscuz BBS论坛系统

    1.准备环节 [root@localhost ~]# unzip ComsenzDiscuz-DiscuzX-master.zip //解包 [root@localhost ~]# cd Discuz ...

  3. javaSript 处理电脑和浏览器pc端缩放对页面的影响

    由于用户的个人习惯或其他原因,可能会调整到电脑上的缩放比例或者浏览器的缩放比例,如果访问页面会看起来比较不好看, 电脑上的缩放: 浏览器上的缩放: 解决方法: function detectZoom( ...

  4. C++ 函数重载和参数的缺省值

    一.函数重载 1.1 重载的起源 自然语言中,一个词可以有许多不同的含义,即该词被重载了.人们可以通过上下文来判断该词到底是哪种含义."词的重载"可以使语言更加简练.例如" ...

  5. tomcat启动项目报404错误

    1.请求的时候报404错误,而且我的请求API地址是/account/sendSmsCode,从后台获取到的竟然变成了/account/account/sendSmsCode. ​ ​ 2.后来发现是 ...

  6. 虚拟机下怎么连接U盘,如何使用U盘?一策书(湘岳阳万江波)的随笔

    准备在虚拟机下,制作U盘启动盘.安装了U盘制作软件,插上U盘却无法识别到.打开虚拟机进行设置,添加USB设备,提示:已达到最大值.怎么回事呢? 原来还需要在宿主机上进行设置. 在宿主机上,运行:ser ...

  7. Spring Security简介与入门Demo

    1:Spring Security简介 Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配 ...

  8. SpringBoot整合junit

    SpringBoot整合junit 主要分为4步 添加依赖 创建测试类 在测试类上添加注解 在测试类注入测试对象 1:导入依赖包 <dependency> <groupId>o ...

  9. Redis学习之Redis服务器数据库实现

    本文内容: 1.Redis服务器保存数据库的方法 2.客户端切换数据库的方法 3.数据库保存键值对的方法 4.数据库的添加,删除,查看,更新操作的实现方法 5.服务器保存键的过期时间的方法 6.服务器 ...

  10. mac下安装和运行redis

    第一部分:安装    第一步:直接从官网下载**.tar.gz这个包.并用tar -zxvf **.tar.gz -C 指定目录 示例命令: tar -zxvf redis-5.0.5.tar.gz ...