选择列表包含未聚合的列

编程入门 行业动态 更新时间:2024-10-26 14:41:12
本文介绍了选择列表包含未聚合的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

自从更新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解决此问题.

更多推荐

选择列表包含未聚合的列

本文发布于:2023-10-14 11:47:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1490968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!