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

tags: Group by statement execution error  sql_mode=only_full_group_by

Today I wrote such a SQL statement in Mysql on my personal server:

select id,name,link,passwd,original,type from movie GROUP BY link;

The execution even reported an error, the error information is as follows:

[2018-07-06 14: 53: 27.339] [000172] [Personal Online Database] [MYSQL]
1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

My Mysql version is 5.7.22, which was newly installed when I was doing my personal project recently. This SQL is implemented in my company's server mysql (version 5.6). There is nothing wrong with it, because the usage of the group by statement is: group by The following fields need to appear after the select or use aggregate functions. The official website checks the explanation of sql_mode = only_full_group_by as follows:

ONLY_FULL_GROUP_BY

Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns.

As of MySQL 5.7.5, the default SQL mode includes ONLY_FULL_GROUP_BY. (Before 5.7.5, MySQL does not detect functional dependency and ONLY_FULL_GROUP_BY is not enabled by default. For a description of pre-5.7.5 behavior, see the MySQL 5.6 Reference Manual.)

A MySQL extension to standard SQL permits references in the HAVING clause to aliased expressions in the select list. Before MySQL 5.7.5, enabling ONLY_FULL_GROUP_BY disables this extension, thus requiring the HAVING clause to be written using unaliased expressions. As of MySQL 5.7.5, this restriction is lifted so that the HAVING clause can refer to aliases regardless of whether ONLY_FULL_GROUP_BY is enabled.

In other words, before 5.7.5, MySQL did not detect functional dependencies, only_full_group_by is not enabled by default, only_full_group_by means that the field of your group by must exactly match the field after the selection (except for aggregation functions) ).

Check the value of the sql_mode attribute in my mysql:

show variables like '%sql_mode%'

The following command resets the value of the sql_mode attribute:

 set session sql_mode='';

I set it to empty directly here. For the specific value of sql_mode, please refer to the official website:sql_mode attribute and value of mysql

Re-execute SQL, OK!

References for this article:mysql official website

Intelligent Recommendation

this is incompatible with sql_mode = only_full_group_by (group By pit)

Error message solve I encountered a SQ pit today, recorded, longji Inappropriate reason Mainly group problems caused, the previous use of the list query, I thought it was a joint watch could not use G...

Solve this is incompatible with sql_mode=only_full_group_by Details

solve this is incompatible with sql_mode=only_full_group_by Details problem Document Sourcehttp://docs.oracle.com/cd/E17952_01/mysql-5.7-en/miscellaneous-functions.html#idm139917231730832 Solution ori...

Mysql5.7 error this is incompatible with sql_mode=only_full_group_by

Solution: 1. View: show result: SET deletes ONLY_FULL_GROUP_BY 2. Modify sql_mode 3. Check the verification again and the modification is successful. The results are as follows: The problem is solved ...

mysql error this is incompatible with sql_mode = only_full_group_by

mysql5.7 + version is turned on by defaultonly_full_group_byMode,When you turn on this mode, the column must query conditions are grouped. The original group by statement will be reported this error. ...

mysql error: this is incompatible with sql_mode=only_full_group_by

Solution: modify the mysql configuration file The local server can modify this Add under [mysqld] Then restart service mysql restart  ...

More Recommendation

MySQL error: this is incompatible with sql_mode = only_full_group_by

Error scenario Today, I have a project that I just came down on my computer. When I log in to enter the home page, I reported a string of this is incompatible with sql_mode = only_full_group_by error,...

Mysql5.7.9 error this is incompatible with sql_mode = only_full_group_by

, I have been using a 5.6 version of MySQL. Recently, it is quite normal before 5.7.9. It is running very normal project error: Which is not functionally dependent on columns in group by clause; this ...

this is incompatible with sql_mode = only_full_group_by error resolution

I found it when I was running code on the host. this is incompatible with sql_mode=only_full_group_by Such a mistake, after an investigation, the final discovery is that the database on the host is ne...

Mysql8 error: this is incompatible with sql_mode = only_full_group_by

MySQL8 version error: this is incompatible with sql_mode = only_full_group_by Use the following command to query the corresponding mode Solution, permanent resolution Modify MY.CNF [MySQLD], join this...

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 ...

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

Top