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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
RDS MySQL Serverless 高可用系列,价值2615元额度,1个月
简介: 报错:[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

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
3月前
|
SQL
[Err] 1052 - Column ‘roleId‘ in where clause is ambiguous
这篇文章解释了SQL查询中出现"Column ‘roleId’ in where clause is ambiguous"错误的原因,即在多表查询中,如果没有明确指定表名,相同的列名在where子句中会产生歧义,并提供了修正方法,即明确指定条件中所引用的列属于哪个表。
|
数据库
解决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
283 0
|
存储 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的解决办法
190 0
|
SQL Java 数据库
解析SQLSyntaxErrorException异常:not in GROUP BY clause
大家好,欢迎阅读我们的文章。今天,我们将讨论一个常见的Java异常——java.sql.SQLSyntaxErrorException,并深入探讨其中一个具体的错误信息:Expression #1 of SELECT list is not in GROUP BY clause。
794 0
解析SQLSyntaxErrorException异常:not in GROUP BY clause
|
SQL 数据库
Unknown column ‘张三‘ in ‘where clause‘
Unknown column ‘张三‘ in ‘where clause‘
139 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异常
132 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
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
202 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语句失效。
364 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
332 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
252 0