本文介绍了选择列表包含未聚合的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
自从更新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'
在没有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/mysqldf
On my Node server with Digital Ocean the conference file I needed to edit was located /etc/mysql/mysql.conf.d/mysqldf
添加以下内容
[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解决此问题.
更多推荐
选择列表包含未聚合的列
发布评论