语法错误或访问冲突:1055 SELECT列表的表达式#8不在GROUP BY子句中,并且包含未聚合的列 [英] Syntax error or access violation: 1055 Expression #8 of SELECT list is not in GROUP BY clause and contains nonaggregated column

查看:611
本文介绍了语法错误或访问冲突:1055 SELECT列表的表达式#8不在GROUP BY子句中,并且包含未聚合的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了CakePHP 3.x"Bookmaker教程",并且逐步遵循了说明.不幸的是,在第一章的结尾我得到了附件错误:

i tried the CakePHP 3.x "Bookmaker Tutorial" and i followed the instruction step by step. Unfortunately, at the end of the first chapter i get the attached error:

Error: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #8 of SELECT list
is not in GROUP BY clause and contains nonaggregated column 'wis.Tags.id' which is not
functionally dependent on columns in GROUP BY clause; this is incompatible with 
sql_mode=only_full_group_by

此外,我获得了检查"BookmarksTags"表的信息,但我不必以前创建一个表.我有点困惑.

Furthermore, i get the information to check my "BookmarksTags" table but i do not have to creat one before. I little bit confused.

Please try correcting the issue for the following table aliases:

BookmarksTags

我已经用谷歌搜索了我的问题,并且发现了用额外的一行来更新"my.cnf"的信息.我已经尝试过了,但是什么都没有.我还检查了拼写并从github下载了"bookmarker-tutorial",但上面仍然出现此错误.

I already google my problem and i found information to update the "my.cnf" with a extra line. i already try but nothing happed. I also check the spelling and downloaded the "bookmarker-tutorial" from github but i still get this error above.

我使用MySQL 5.7.11和PHP 5.6.14.

I use MySQL 5.7.11 and PHP 5.6.14.

推荐答案

这是MySQL 5.7中的新事物,它警告您的查询不明确.

This is a new thing in MySQL 5.7 and is a warning that your query is ambiguous.

请考虑下表:

id    |   name    |   age    |   points
--------------------------------------------
1         Bob         21         1
2         James       14         1
3         Bob         21         3
4         James       14         2
5         Casey       17         3

如果您执行以下查询:

SELECT name, age, SUM(points) FROM scores GROUP BY name

然后name列用于分组.请注意,age可能具有多个值,因此它是非聚合的".您需要采取一些措施来缩小这些值.

Then the name column is used for grouping. Note that age may have multiple values, so it's "non-aggregated". You need to do something to collapse down those values.

5.6和以前版本中的行为是根据排序顺序选择第一个,尽管有时这是不可预测的,并且会失败.在5.7中,他们一开始就阻止您这样做.

The behaviour in 5.6 and previous was to just pick the first one depending on sort order, though this was sometimes unpredictable and would fail. In 5.7 they're preventing you from doing it in the first place.

这里的解决方案是对它进行分组,或者对它应用聚合运算符,例如MIN().

The solution here is to group on that as well, or to apply an aggregate operator like MIN() to it.

这篇关于语法错误或访问冲突:1055 SELECT列表的表达式#8不在GROUP BY子句中,并且包含未聚合的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆