且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SELECT 列表不在 GROUP BY 子句中并且包含非聚合列 .... 与 sql_mode=only_full_group_by 不兼容

更新时间:2021-11-09 22:10:30

这个

SELECT 列表的表达式 #1 不在 GROUP BY 子句中,并且包含在功能上不依赖于 GROUP BY 子句中的列的非聚合列returntr_prod.tbl_customer_pod_uploads.id";这与 sql_mode=only_full_group_by 不兼容

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'returntr_prod.tbl_customer_pod_uploads.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

通过这个命令改变MySQL中的sql模式就可以解决了,

will be simply solved by changing the sql mode in MySQL by this command,

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

这对我也有用..我用了这个,因为在我的项目中有很多这样的查询所以我只是将这个sql模式改为only_full_group_by

This too works for me.. I used this, because in my project there are many Queries like this so I just changed this sql mode to only_full_group_by

或者简单地包括 SELECT 语句指定的 GROUP BY 子句中的所有列.sql_mode 可以保持启用状态.

OR simply include all columns in the GROUP BY clause that was specified by the SELECT statement. The sql_mode can be left enabled.

谢谢... :-)