Mysql Group By与sql_mode = only_full_group_by不兼容

时间:2018-06-22 15:29:48

标签: java mysql tomcat7

sql查询:

选择,将sum(field1)作为sumfield1,从knowntable中匹配(生产者) 以sumfield1> 0的生产者为对象(在布尔模式下反对('+ xyz ')布尔型) 按sumfield1 desc限制10排序;

在使用本地tomcat运行时引发以下异常:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

以上查询在生产系统/ tomcat中运行正常。这两个服务器(本地服务器和生产服务器)都在访问相同的数据库。

我已经尝试了以下解决方案:

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

2) Add the following lines in the /etc/mysql/conf.d/disable_strict_mode.cnf file:
[mysqld]
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

我已经检查了该网站上的所有答案,但有相关的例外情况,但是没有解决方案对我有用

请帮助

0 个答案:

没有答案
相关问题