MYSQL数据查询出现GROUP BY语句出错,提示异常代码1055
输入的查询语句:
SELECT diaryTypeId,typeName,COUNT(diaryId) AS diaryCount FROM t_diary RIGHT JOIN t_diaryType ON t_diary.typeId=t_diaryType.diaryTypeId GROUP BY typeName;
报错提示信息:
1 queries executed, 0 success, 1 errors, 0 warnings
查询:SELECT diaryTypeId,typeName,COUNT(diaryId) as diaryCount FROM t_diary RIGHT JOIN t_diaryType ON t_diary.typeId=t_diaryType.diary...
错误代码: 1055
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'db_diary.t_diaryType.diaryTypeId' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
执行耗时 : 0 sec
传送时间 : 0 sec
总耗时 : 0.007 sec
解决办法:
找到MySQL安装目录下的my.ini
在sql_mode 中去掉only_full_group_by , 即:
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
修改完成之后,重启数据库,然后再打开,再次查询就正常了。