MYSQL报错:1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated col

Posted 一沙世界

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MYSQL报错:1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated col相关的知识,希望对你有一定的参考价值。

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_value(field)函数,他主要的作用就是抑制ONLY_FULL_GROUP_BY值被拒绝

官方有介绍,地址:https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_any-value

我们可以把select语句中查询的属性(除聚合函数所需的参数外),全部放入any_value(field)函数中;

例如:select name,any_value(sex) from test_table group by name

这样sql语句不管是在ONLY_FULL_GROUP_BY模式关闭状态还是在开启模式都可以正常执行,不被mysql拒绝。

以上是关于MYSQL报错:1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated col的主要内容,如果未能解决你的问题,请参考以下文章

MySQL 报错 1055

MySQL_group by报错 [ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause]

MySQL-[Err] 1055 - Expression #1

MySQL报错1055- Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

MySQL报错1055- Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated colum

MySQL报错1055- Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated colum