错误:
code: 'ER_WRONG_FIELD_WITH_GROUP', errno: 1055,
code: 'ER_MIX_OF_GROUP_FUNC_AND_FIELDS', errno: 1140
不同的错误取决于一些更改,我试图避免错误。在我的Node.js:中中断的查询
'SELECT e.eventName, e.eventDesc, COUNT(ua.eventID) AS cnt '
+ 'FROM charitydb.events AS e, charitydb.user_activity AS ua '
+ 'WHERE e.eventID = ua.eventID '
+ 'GROUP BY e.eventName '
+ 'ORDER BY cnt DESC'
无法禁用ONLY_FULL_GROUP_BY,因为GCP上没有超级权限
正如Guillaume在评论中建议的那样,自MySQL 5.7.5(源代码(以来,默认情况下会启用此模式,并且由于GCP不允许用户拥有作为托管服务的SUPER权限,因此您需要对所有选定字段执行完整的GROUP子句。
所以,你的固定代码是:
'SELECT e.eventName, e.eventDesc, COUNT(ua.eventID) AS cnt '
+ 'FROM charitydb.events AS e, charitydb.user_activity AS ua '
+ 'WHERE e.eventID = ua.eventID '
+ 'GROUP BY e.eventName, e.eventDesc '
+ 'ORDER BY cnt DESC'
有关MySQL如何处理组的更多信息,请点击此处。