码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2019-12-01 00:38:33      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:dep   pat   field   pac   mys   use   end   and   函数   

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 column

标签:dep   pat   field   pac   mys   use   end   and   函数   

原文地址:https://www.cnblogs.com/yoyotl/p/11964460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!