遇到数据库的错误

1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'school_test.score.c_no'; this is incompatible with sql_mode=only_full_group_by

[42000][1055] Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'crm.a.text' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

1.查看sql_mode

show variables like '%sql_mode';  
show session variables like '%sql_mode%';  
show global variables like '%sql_mode%';  

2.修改sql_mode

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

set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

sql_model后面的值就是上面查询出来的值去掉ONLY_FULL_GROUP_BY****

posted @ 2020-09-18 16:18  Tony小哥  阅读(270)  评论(1编辑  收藏  举报