which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod

在进行按组查询的时候,报错

-- 按分组查询
select * from my_student group by class_id;

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mydatabase1.my_student.stu_id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

在确认不是拼写错误之后,找到原因:在sql_mode里面,group by 与 only_full_group_by 不兼容

在my.ini 文件里,修改sql_mode的值

 

which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod_第1张图片

并重启mysql服务

which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod_第2张图片

 

再重新输入语句,查询正常!

 

 

 

你可能感兴趣的:(MySQL,生活)