mysql5.7 group by syntax 1055

mysql5.7 group by syntax 1055

First look at the following statement to query the engine table that exists by default

 The MySQL version used before is below 5.7, and the execution statements are grouped according to support as follows

Add a field engine that has nothing to do with the group support

There is no problem

The current version is 5.7

After grouping according to support

1055-Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column'information_schema.ENGINES.ENGINE' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

meaning is

The SELECT list is not in the GROUP BY clause and contains the non-aggregated column'information_schema. engine. Functionally does not depend on the columns in the GROUP BY clause; this is not compatible with sql_mode=only_full_group_by

That is, the columns displayed by select must be related to group by

This is consistent with the oracle group by syntax, I have to say, it is more reasonable, of course, some viewing statements should be more complicated

View system variables sql.mode 

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Modification method, edit my.ini in window, my.cnf in Linux, delete ONLY_FULL_GROUP_BY in [mysqld], and restart to solve!

Reference: https://cloud.tencent.com/developer/article/1456256 mysql5.7 group by Grammar 1055-Cloud + Community-Tencent Cloud