选择列表包含未聚合的列 [英] Select list contains nonaggregated column

查看:224
本文介绍了选择列表包含未聚合的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从更新MySQL之后,我注意到以下查询失败

Since updating MySQL I've noticed the following query fails

SELECT u.*, p.name as plan, COUNT(u.id) as totalprojects FROM users u LEFT JOIN plans p ON p.id = access LEFT JOIN maps m ON m.user_id = u.id WHERE u.email = 'john@doe.com'

在没有GROUP BY的聚合查询中,SELECT列表的表达式#1 包含未聚合的列'kontakt.u.id';这是不兼容的 使用sql_mode = only_full_group_by

In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'kontakt.u.id'; this is incompatible with sql_mode=only_full_group_by

有人知道如何修复此查询以对错误进行排序吗?

Does anyone know how to get this query fixed to sort the error?

推荐答案

在具有Digital Ocean的节点服务器上,我需要编辑的会议文件位于/etc/mysql/mysql.conf.d/mysqld.cnf

On my Node server with Digital Ocean the conference file I needed to edit was located /etc/mysql/mysql.conf.d/mysqld.cnf

添加以下内容

[mysqld] sql_mode = "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

然后service mysql restart解决此问题.

这篇关于选择列表包含未聚合的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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