Get the App
SLTechnology News&Howtos  ›  Database  › 

Resolve packet error reporting Expression # 1 of SELECT list is not in GROUP BY clause and contains nonaggregated for mysql greater than version 5.7

Shulou Source: shulou.com Published: 2022-06-01 04:29:43 11月14日 Update

Reason:

MySQL 5.7.5 and up implement the detection of functional dependencies. If only_full_group_by SQL mode is enabled (as is the default), MySQL rejects queries referenced by lists, conditions, or sequential lists that reference unnamed non-aggregate columns in the group, rather than relying on them functionally. Prior to 5.7.5, MySQL did not detect functional dependencies, and only_full_group_by was not enabled by default. For a description of the previous 5.7.5 behavior, see the MySQL 5.6 reference manual.)

Execute the following command to view the contents of sql_mode:

Mysql > SHOW SESSION VARIABLES;mysql > SHOW GLOBAL VARIABLES;mysql > select @ @ sql_mode

It can be seen that the values of sql_mode for both session and global are:

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

Only_full_group_by description:

Only_full_group_by: to use this is to use the same group rules as oracle. The columns of select must be in group, or they must be SUM,AVG,MAX,MIN. In fact, this configuration is similar to distinct at present, so it is good to remove it.

Resolve:

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';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'

Summary

The above is introduced by the editor to solve the group error report Expression # 1 of SELECT list is not in GROUP BY clause and contains nonaggregated of the larger than 5.7version of mysql. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!

If you think this article is helpful to you, you are welcome to reprint it, please indicate the source, thank you!

Tags: Function situation help query test version grouping almost individual content provenance reason command that is feeling manual is in condition mode question Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Shulou Technology Redmi MariaDB