mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题

报错如下:

Expression #2 of SELECT list is not in GROUP BY clause and contains

nonaggregated column ‘sss.month_id’ which is not functionally

dependent on columns in GROUP BY clause; this is incompatible with

sql_mode=only_full_group_by

问题出现的原因: 
MySQL 5.7.5及以上功能依赖检测功能。如果启用了ONLY_FULL_GROUP_BY SQL模式(默认情况下),MySQL将拒绝选择列表,HAVING条件或ORDER BY列表的查询引用在GROUP BY子句中既未命名的非集合列,也不在功能上依赖于它们。(5.7.5之前,MySQL没有检测到功能依赖关系,默认情况下不启用ONLY_FULL_GROUP_BY。有关5.7.5之前的行为的说明,请参见“MySQL 5.6参考手册”。)

解决方法一:

打开navcat,

用sql查询:

select @@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,重新设置值。

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’;

如下图:

解决方法二:

成功的步骤:

iterm打开

sudo vim /etc/mysql/conf.d/mysql.cnf

滚动到文件底部复制并粘贴

[mysqld]

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

到文件的底部

保存并退出输入模式

sudo service mysql restart

重启MySQL。

完成!

如下图: 

原文地址:https://blog.csdn.net/plpldog/article/details/82794459

原文地址:https://www.cnblogs.com/jpfss/p/11125782.html

时间: 2024-09-28 03:16:21

mysql遇见Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre的问题的相关文章

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre

原文链接:https://blog.csdn.net/hq091117/article/details/79065199 https://blog.csdn.net/allen_tsang/article/details/54892046 MySQL 5.7.5后only_full_group_by成为sql_mode的默认选项之一,这可能导致一些sql语句失效. 比如下表game: id group_id name score 1 A 小刚 20 2 B 小明 19 3 B 小花 17 4 C

mysql报错:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre

原因: https://blog.csdn.net/fansili/article/details/78664267 解决办法: 1:查看mysql配置文件位置 [root@localhost ~]# ps -ef | grep mysql mysql 838 1 0 02:21 ? 00:00:00 /usr/sbin/mysqld --defaults-file=/etc/my.cnf root 2035 1706 0 02:29 pts/0 00:00:00 grep --color=au

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 'rpacloudsit.t.app_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by MySQL有any_

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: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tt.from_id' which is not functionally dependent on columns in GRO

mysql问题解决SELECT list is not in GROUP BY clause and contains nonaggregated column

今天在Ubuntu下的部署项目,发现一些好好的列表页面发生 1055:Expression #11 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'ppm_c.ppm_flow_starting_dealing.status' which is not functionally dependent on columns in GROUP BY clause; this is incompati

SELECT list is not in GROUP BY clause and contains nonaggregated

安装了mysql5.7,用group by 查询时抛出如下异常 SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'kanxf.o.down_uid' which is not functionally dependent on columns in GROU

【MySQL】出现“SELECT list is not in GROUP BY clause and contains xxx”错误提示

需要设置为 sql_mode='NO_ENGINE_SUBSTITUTION' 设置方式: 1.MySQL客户端连接上数据库. 2.当前操作的数据切换成 mysql 3.执行 SELECT @@global.sql_mode 4.执行 SET GLOBAL sql_mode='NO_ENGINE_SUBSTITUTION'; 成功解决.

SELECT list is not in GROUP BY clause and contains

查询mysql 相关mode select @@global.sql_mode; 可以看到模式中包含了ONLY_FULL_GROUP_BY,只要没有这个配置即可. 我的Mysql版本是5.7.21,默认是带了ONLY_FULL_GROUP_BY模式. ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION 2.重设模式

mysql查询出现In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'zhibo.a.id';

出现问题: Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP BY,expression #2 of SELECT list contains nonaggregated column 'pay.t.type'; this is incompatible with sql_mode=only_fu