在执行SQL查询时报错
错误信息
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: expression #1 of SELECt list is not in GROUP BY clause and contains nonaggregated column 'cmd.member_icon' 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 file [/Users/cunweizhao/Desktopapi/target/classes/mapper/ClGiftInfoUserRecordMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT cmd.member_icon userIcon, cgiur.gift_img giftImage, cgiur.gift_name giftName, COUNT( cgiur.gift_name ) giftNum FROM cl_gift_info_user_record cgiur JOIN cl_member_detail cmd ON cgiur.create_member_id = cmd.member_id WHERe cgiur.receive_member_id = ? GROUP BY cgiur.gift_name ORDER BY cgiur.price, cgiur.create_time DESC; ### Cause: java.sql.SQLSyntaxErrorException: expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column '.cmd.member_icon' 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 java.sql.SQLSyntaxErrorException: expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column '.cmd.member_icon' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by Creating a new SqlSession解决方式:
我是直接通过如下命令解决的问题:
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';



