jdbc4.MySQLSyntaxErrorException:Expression #2 of SELECT list is not in GROUP BY clause and contains

本文介绍了解决Eclipse JavaWeb项目中遇到的ONLY_FULL_GROUP_BY限制导致的问题。通过修改全局SQL_MODE,去除ONLY_FULL_GROUP_BY,确保查询正常进行。

今天在用eclipse做java web项目时,遇到这样一个坑


用sql查询:

select @@global.sql_mode

查询出来的值为:

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

去掉ONLY_FULL_GROUP_BY,重新设置值。

set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tc_oauth2.sa.app_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by ### The error may exist in com/citycloud/ccuap/tc/admin/projectapp/SysAppMapper.java (best guess) ### The error may involve com.citycloud.ccuap.tc.admin.projectapp.SysAppMapper.querySysAppPage-Inline ### The error occurred while setting parameters ### SQL: SELECT sa.app_name AS appName,sa.client_id AS clientId,oc_d.resource_ids AS resource,oc_d.authorized_grant_types AS authorizedGrantTypes,GROUP_CONCAT(sp.project_id) AS projectIds FROM sys_app AS sa LEFT JOIN sys_project AS sp ON sa.client_id = sp.client_id LEFT JOIN oauth_client_details AS oc_d ON oc_d.client_id = sa.client_id WHERE 1 = 1 group by sa.client_id order by sa.app_id desc LIMIT 0,10 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tc_oauth2.sa.app_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 #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tc_oauth2.sa.app_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tc_oauth2.sa.app_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 这个应该是数据配置的问题,帮我看看怎么修改数据库配置
03-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值