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

扫描二维码关注公众号,回复: 279339 查看本文章

执行耗时   : 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'

修改完成之后,重启数据库,然后再打开,再次查询就正常了。

猜你喜欢

转载自salmon2016.iteye.com/blog/2328255