MYSQL data query GROUP BY statement error, prompting error code 1055

Entered query statement:

SELECT diaryTypeId,typeName,COUNT(diaryId) AS diaryCount FROM t_diary RIGHT JOIN t_diaryType ON t_diary.typeId=t_diaryType.diaryTypeId GROUP BY typeName;

 

Error message:

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...

 

Error code: 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

 

Execution time : 0 sec

Transmission time : 0 sec

Total time : 0.007 sec

 

Solution:

Find my.ini in the MySQL installation directory

Remove only_full_group_by in sql_mode, ie:

 

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

 

After the modification is completed, restart the database, then open it again, and query again is normal.

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326614136&siteId=291194637