MySQL is using group by query error this is incompatible with sql_mode=only_full_group_by

The specific errors are as follows:

 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'zl.tm.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

the reason:

MySQL 5.7.5 and above functions depend on the detection function. If ONLY_FULL_GROUP_BY SQL mode is enabled (by default), MySQL will reject select lists, HAVING conditions, or ORDER BY list query references that are neither named non-collection columns in the GROUP BY clause, nor are they functionally dependent on them. (Before 5.7.5, MySQL did not detect functional dependencies, and ONLY_FULL_GROUP_BY is not enabled by default.

Solution:

1. Query mysql related mode

select @@global.sql_mode;

You can see that ONLY_FULL_GROUP_BY is included in the pattern, as long as there is no such configuration. A
My MySQL version is 5.7.21, the default is with ONLY_FULL_GROUP_BY mode.

2. Reset the mode value

Set via configuration file: vim /etc/my.cnf
Add the following configuration to my.cnf (my.ini):
[mysqld]
sql_mode='The mode you want'

Such as:

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

In windows as shown:

In query mode:

There is no ONLY_FULL_GROUP_BY mode anymore.

The test sql query was successful.

Intelligent Recommendation

MySQL error [this is incompatible with sql_mode = only_full_group_by]

Report error message: Reporting error Mysql 5.7.5 and above function dependencies. If ONLY_FULL_GROUP_BY is enabled SQL Mode (By default), MySQL will refuse to select a list, the Having condition, or ...

Mysql Group by error: 1055-Expression #1GROUP BY this is incompatible with sql_mode=only_full_group_by

Original link: https://blog.csdn.net/loveliness_peri/article/details/88051316   The reason for the problem: there are more in sql_mode:ONLY_FULL_GROUP_BY Use SQL statements to query this configur...

Solution: MySQL Error 1055: Group by clause; this is incompatible with sql_mode = only_full_group_by

When using MySQL to perform Group By query statement, error: problem causes The SQL standard does not allow the Select list, a Having condition statement, or a grouse in the Group By in the Order by s...

Laravel query mysql error Laravel this is incompatible with sql_mode = only_full_group_by

During the query with laravel, Daravel this is incompatible with sql_mode = only_full_group_by Looked online, because MySQL version is compatible, I use 5.7, add [mysql] and [mysqld], add additional f...

More Recommendation

In aggregated query without GROUP BY...this is incompatible with sql_mode=only_full_group_by

When querying a database, the following error occurs: Details are as follows: This is caused by improperly setting sql_mode. Modify sql_mode to: Inquire: 1. Method 1 modify Check again: This modificat...

MySql version changes, and an error is reported when using group by for group query sql_mode=only_full_group_by

1. Reason of error After MySQL 5.7.5, only_full_group_by becomes one of the default options of sql_mode, which may cause some SQL statements to fail. For example, when group by is used for group query...

Solve the Group By statement error: this is incompatible with sql_mode = only_full_group_by

Today I wrote such a SQL statement in Mysql on my personal server: The execution even reported an error, the error information is as follows: My Mysql version is 5.7.22, which was newly installed when...

mysql5.7 query error this is incompatible with sql_mode = only_full_group_by

The server is running normally, and an error occurs when the machine is running Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘mgl.db_mglmro_customer_c...

MYSQL8.0 sort query error this is incompatible with sql_mode=only_full_group_by

Edit the mysql configuration file (windows is my.ini, linux is my.cnf), add the following configuration under [mysqld]:   Just restart the MySQL service...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top