mysql group by与sql不兼容\u mode=only\u full\u group by

dgsult0t  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(251)

sql查询:
选择sumfield1>0 order by sumfield1 desc limit 10,sumfield1作为sumfield1,从knowntable where match(producer)against(“+xyz”在布尔模式下)group by producer;
使用本地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中运行良好。两个服务器(本地和prod)都在访问同一个数据库。
我已经尝试了以下解决方案:

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

我已经检查了所有的答案在这个网站上与相关的例外,但没有解决办法是为我工作
请帮忙

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题