select * where dept.path like concat(?,'%') AND cc.charge_id
in (2638952438426624,2644398611229696,2648683693877248) group by SUBSTRING_INDEX(dept.path,':',1)
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression
#2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'crm.dept.path_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'crm.dept.path_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by此错误是由于mysql5.7及其以上版本默认是严格分组模式,不允许group by 分组字段之外的字段出现select后面,如果group by之外的字段是必须使用的 则需要采用聚合MAX(),SUM等一些函数将字段或结果合并。
解决办法(针对linux版本) :
打开mysql命令行,执行命令:
select @@sql_mode
查出sql_mode的值,复制这个值,在my.cnf中添加配置项(把查询到的值删掉only_full_group_by这个选项,其他的都复制过去)
sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
如果 [mysqld] 这行被注释掉的话记得要打开注释。然后重重启mysql服务。