文档章节

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

yizhichao
 yizhichao
发布于 2017/04/07 13:35
字数 416
阅读 1.5K
收藏 0

#程序员薪资揭榜#你做程序员几年了?月薪多少?发量还在么?>>>

今天视频平台有一个统计查询失败

SELECT
	s.schoolName,
	s.classname,
	count(s.resourceId) AS count
FROM
	tbl_school_class_lens_info s,
	tbl_player_statistics p
WHERE
	s.resourceId = p.resourceId
GROUP BY
	s.resourceId

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

官方说法

https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html

查询mysql 相关mode

[root@localhost home]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1147
Server version: 5.7.16 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 
mysql> 
mysql> show variables like '%sql_mode%'
    -> ;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name | Value                                                                                                                                     |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
| 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 |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select version(), @@sql_mode;
+-----------+-------------------------------------------------------------------------------------------------------------------------------------------+
| version() | @@sql_mode                                                                                                                                |
+-----------+-------------------------------------------------------------------------------------------------------------------------------------------+
| 5.7.16    | 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 |
+-----------+-------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> exit

 

发现 里面 有  ONLY_FULL_GROUP_BY , 所有将其去掉

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

 

[root@localhost ~]# cat /etc/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[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'
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#skip-grant-tables
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[client]
socket =/var/lib/mysql/mysql.sock

 

然后重启mysql

[root@localhost ~]# service mysqld stop
Redirecting to /bin/systemctl stop  mysqld.service

[root@localhost ~]# 
[root@localhost ~]# service mysqld start
Redirecting to /bin/systemctl start  mysqld.service
[root@localhost ~]# 

 

© 著作权归作者所有

yizhichao

yizhichao

粉丝 16
博文 477
码字总数 365637
作品 0
南京
程序员
私信 提问
加载中

评论(0)

解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'i...

解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat 转自:https://blog.csdn.net/HaHa_Sir/article/details/80503601 2018年05月......

osc_y7snjgcc
2019/02/19
234
0
MySQL升级到5.7.16 遇到的问题"[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause...

问题:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally depe......

osc_29lf73z8
2019/05/08
28
0
Mysql 8.x [Err] 1055 only_full_group_by 问题记录

查询时报错 [Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ' 解决方法: 登录mysql 后可以查看sql_mode show variables like '%......

kdy1994
2018/11/07
479
0
【Linux】【mysql】mysql8.0开启远程访问及常见问题

1.连接数据库 1 [root@localhost ~]# mysql -uroot -p 2 Enter password: 3 Welcome to the MySQL monitor. Commands end with ; or g. 4 Your MySQL connection id is 17 5 Server version:......

osc_edtw4h1l
2019/09/17
1
0
mysql 高版本only_full_group_by 错误

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent ......

osc_k6lb5e4x
2019/04/09
8
0

没有更多内容

加载失败,请刷新页面

加载更多

如何制作出色的R可重现示例 - How to make a great R reproducible example

问题: This post is a Community Wiki . 这篇文章是社区维基 。 Edit existing answers to improve this post. 编辑现有答案以改善此职位。 It is not currently accepting new answers. 它......

技术盛宴
14分钟前
24
0
windows下修改默认mysql编码

查看编码格式: 进入mysql执行下面语句 show variables like '%character%'; 修改编码格式: set character_set_client=utf8;set character_set_connection=utf8;set character_set_da......

珞木橘子
19分钟前
21
0
ArrayList与LinkList性能对比----新增元素

在聊到 ArrayList 和 LinkList 的时候都会这么说 ArrayList 底层是基于数组实现的内存地址物理上是连续的,新增,删除效率低,查询效率高 LinkList 是基于链表实现的,逻辑地址是连续的内存地...

Lbj虞
40分钟前
34
0
Nginx

想了解nginx的代理可以先看这篇: https://baijiahao.baiducom/s?id=1652608869911988442&wfr=spider&for=pc nginx常用命令 nginx -t ##检查配置文件,一般修改完配置文件都建议一定先执行这...

UItraman
昨天
24
0
新基建的福音:智慧楼宇可视化监控系统引领智能化新时代

前言 智慧楼宇和人们的生活息息相关,楼宇智能化程度的提高,会极大程度的改善人们的生活品质,在当前工业互联网大背景下受到很大关注。目前智慧楼宇可视化监控的主要优点包括: 智慧化 -- 智...

xhload3d
昨天
19
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部