The following error is reported when searching or inserting data in the mysql tool:
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘database_tl.emp.id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
the reason:
Take a look at the syntax of group by:
select select the column in the group + aggregate function from the table name group by grouped column
From the perspective of grammatical format, the grouping is first, and then the columns to be retrieved are determined. The columns to be retrieved can only be selected among the columns participating in the grouping.
My current Mysql version 5.7.17,
Look again at ONLY_FULL_GROUP_BY means: for the GROUP BY aggregation operation, if the column in the SELECT does not appear in the GROUP BY, then this SQL is illegal, because the column is not in the GROUP BY clause, that is to say, it is detected The column must appear after the group by, otherwise an error will be reported, or this field appears in the aggregate function.
View the mysql version command: select version();
View the sql_model parameter command:
SELECT @@GLOBAL.sql_mode;
SELECT @@SESSION.sql_mode;
Find:
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
The first item turns ONLY_FULL_GROUP_BY by default,
Solution:
1. Select only the columns that appear behind the group by, or add aggregate functions to the columns; (not recommended)
2. Command line input:
set @@GLOBAL.sql_mode=”;
set sql_mode =’STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
Turn off ONLY_FULL_GROUP_BY by default!
Use the tool to select at this time
SELECT @@sql_mode;
SELECT @@GLOBAL.sql_mode;
Found that ONLY_FULL_GROUP_BY does not exist anymore, it feels OK. But if you restart the Mysql service, you will find that ONLY_FULL_GROUP_BY will still exist
If you want to completely solve this problem, you have to change the my.ini configuration (if your mysql does not have this file, change my-default.ini to my.ini, my version does not have the my.ini configuration problem)
Add under [mysqld] and [mysql]
sql_mode =’STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
Read More:
- [Solved] MYSQL 5.7 gruop by eRROR: this is incompatible with sql_mode=only_full_group_by
- [Solved] MYSQL Start Project Error: this is incompatible with sql_mode=only_full_group_by
- [Solved] MySQL Error: ERROR 1055 (42000)sql_mode=only_full_group_by
- How to Solve MySQL version 5.7+ Group by group error
- [Solved] MySQL Error: “Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”
- [MySQL] The principle of group by aggregation function and the reason for aggregation limitation SELECT list is not in GROUP BY clause and contains nonaggregated column
- [Solved] ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate
- SQL Server Group sort de duplication row_ number() over ( PARTITION BY t1.col_ 2 ORDER BY 1 )
- [Solved] Sequelize DatabaseError: ER_WRONG_FIELD_WITH_GROUP: Expression #2 of SELECT list is not in GROUP
- [Solved] MySQL: Syntax error or access violation: 1055 Expression #1 of SELECT list is not …
- [Two Methods] Ora-00904: invalid group by error identifier
- postgresql-Database query problem-ERROR: column “t.domainid“ must appear in the GROUP BY clause or be used in an a
- MySQL OrderBy Error: Expression #1 of ORDER BY
- MySQL 8.0.12 runs SQL error #1055 [How to Solve]
- Caused by: java.sql.SQLTransientConnectionException: HikariPool-1 – Connection is not available, request timed out after 30005ms.
- [Solved] Error response from daemon: Conflict. The container name “/mysql is already in use by container
- java.sql.SQLException: Disk full (/tmp/#sql_1eaa2_60.MAI); waiting for someone to free some space
- [Solved] MySQL5.6.44 [Err] 1067 – Invalid default value for create_date settlement programme
- How to Solve mysql [Err] 1067-Invalid default value for
- [Solved] Caused by: java.sql.SQLException: Access denied for user ‘root‘@‘hadoop102‘ (using password: YES)