报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介: 报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregat

在Navicat中执行SQL语句时,报以下错:


[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 on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by


解决方法一:

在MySQL中执行:


select version(),

@@sql_mode;SET sql_mode=(SELECT REPLACE(@@sql_mode,‘ONLY_FULL_GROUP_BY’,’’));


这个方法只能解决当前的,最佳答案还是用解决方法二。


解决方法二:

修改MySQL的配置文件 my.ini,在[mysqld] 下面增加代码:


sql_mode=‘STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION’


如图:


image.png

image.png


修改完my.ini文件后需要重启一下MySQL服务,如果是windows系统,则执行:

net stop mysql

net start mysql


image.png

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
7月前
|
数据库
解决which is not functionally dependent on columns in GROUP BY clause;...sql_mode=only_full_group_by
解决which is not functionally dependent on columns in GROUP BY clause;...sql_mode=only_full_group_by
57 0
|
9月前
|
存储 SQL 关系型数据库
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的解决办法
97 0
|
10月前
|
SQL Java 数据库
解析SQLSyntaxErrorException异常:not in GROUP BY clause
大家好,欢迎阅读我们的文章。今天,我们将讨论一个常见的Java异常——java.sql.SQLSyntaxErrorException,并深入探讨其中一个具体的错误信息:Expression #1 of SELECT list is not in GROUP BY clause。
356 0
解析SQLSyntaxErrorException异常:not in GROUP BY clause
|
SQL 数据库
Unknown column ‘张三‘ in ‘where clause‘
Unknown column ‘张三‘ in ‘where clause‘
89 0
|
SQL 关系型数据库 MySQL
解决Mysql5.7以上版本, 使用group by抛出Expression #1 of SELECT list is not in GROUP BY clause and contains no异常
解决Mysql5.7以上版本, 使用group by抛出Expression #1 of SELECT list is not in GROUP BY clause and contains no异常
110 0
|
SQL
ORDER BY && GROUP BY
ORDER BY && GROUP BY
73 0
ORDER BY && GROUP BY
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
179 0
1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause
|
SQL 关系型数据库 MySQL
【已解决】SELECT list is not in GROUP BY clause and contains nonaggregated column
MySQL5.7.5后only_full_group_by成为sql_mode的默认选项之一,这可能导致一些sql语句失效。
201 0
|
PHP
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
239 0
【PHP报错集锦】Integrity constraint violation: 1052 Column 'vt_id' in where clause is ambiguous
|
SQL 关系型数据库 MySQL
MySQL - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
MySQL - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
168 0