Code Example Illustrating SQL MySQL Error Code 1055: A Rephrased Guide

The SELECT list has an expression (#2) that is not included in the GROUP BY clause and includes a nonaggregated column ‘mydb.term.year’ that is not functionally dependent on the columns in the GROUP BY clause. This is incompatible with sql_mode=only_full_group_by.
Solution 1: To resolve the error, you should remove any columns in the SELECT list that are not aggregated or included in the GROUP BY clause. The ORDER BY clause also has an expression (#1) that is not in the GROUP BY clause and contains a nonaggregated column, which is not functionally dependent on the columns in the GROUP BY clause. This is incompatible with sql_mode=only_full_group_by.
mysql split explode.

Error Code: 1055. Expression #2 of
select list is not in group by clause and contains nonaggregated column
‘mydb.term.year’ which is not functionally dependent on columns in group by clause; this is incompatible with sql_mode=only_full_group_by
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
Expression number 1 of
Select list is not in group by clause
mysql> 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';
mysql> 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';

Frequently Asked Questions

Posted in Sql