问题:我在线下进行查询时,sql不报错,将代码部署到线上后,却发现抛出如下异常:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'cis.q1.query_date'
which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
线上我们的mysql版本用的是5.7以上的版本,而线下我用的mysql版本比较低。在5.7以后 only_full_group_by 模式是默认开启的,我们需要将其关闭。
在mysqlke可以执行我们的命令:
SET GLOBAL sql_mode = ‘modes’;
SET SESSION sql_mode = ‘modes’;
推荐如下博客:
https://blog.csdn.net/qq_24038207/article/details/79358644