mysql5.7+的group by 报错

[Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'gsms.shield_infomaction.shield_Id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

原因:

    我安装的是mysql5.7+,默认是开启了 only_full_group_by 模式的,从而导致GROUP BY 语句报错

解决:

第一步:查看当前的sql_mode

select @@sql_mode

第二步:

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';

第三步:

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

 

你可能感兴趣的:(mysql5.7+的group by 报错)