[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'gsms.shield_infomaction.shield_Id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
我安装的是最新版的mysql5.7.x版本,默认是开启了 only_full_group_by 模式的,从而导致GROUP BY 语句报错。
可以参考官方文档:https://dev.mysql.com/doc/refman/5.7/en/group-by-handling.html //GROUP BY
https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_only_full_group_by //sql_mode
https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_any-value //any-value
第一想法就是怎么关闭这个模式,但这个模式是默认开启的,如果关闭模式会不会有其它影响,我在网上查到有个函数可以解决这个问题。
在 mysql 中有一个函数: any_value(field) 允许,非分组字段的出现(和关闭 only_full_group_by 模式有相同效果)。
有这个函数就可以解决我的问题了,only_full_group_by 模式是否默认开启在于你们怎么使用。
还有其它解决方法,请参考:http://blog.csdn.net/wangyunfeis/article/details/77911704
sql_mode的几种模式我还需要去了解下的。
---------------------
作者:如同丶
来源:CSDN
原文:https://blog.csdn.net/q3229270/article/details/78319718
版权声明:本文为博主原创文章,转载请附上博文链接!