mysql出现which is not functionally dependent on columns in GROUP BY clause报错解决方案
一、解决
方案一:修改SQL语句,每个字段前加上any_value
方案二:修改数据库配置
1 查询sql模式
mysql> select @@sql_mode;
2 修改配置文件D:\mysql\mysql-5.7.22-winx64my.ini
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
二、sqlalchemy 可使用用如下
_query_channel = db.session.query(A.id, A.name, func.count(A.id).label('num')). group_by('id')
或者使用 from_statement语句
session.query("myid", "myname", "num").from_statement(text("SELECT A.id AS myid, any_value(A.name) AS myname, count(A.id) AS num FROM A GROUP BY A.id"))
参考
https://blog.csdn.net/qq_42175986/article/details/82384160
https://blog.csdn.net/qq_33621326/article/details/95950264
阅读(939) | 评论(0) | 转发(0) |