tags: only_full_group_by mysql
During MySQL operation, the following errors are often reported:
[Err] 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
1. The cause of the error
This error occurs in MySQL version 5.7 and above:
The default sql configuration of mysql version 5.7 is: sql_mode = "ONLY_FULL_GROUP_BY", this configuration strictly implements the "SQL92 standard".
When upgrading from 5.6 to 5.7, in order to be compatible with the syntax, most of them will choose to adjust sql_mode to keep it consistent with 5.6, in order to be compatible with the program as much as possible.
Solution
1. Modify the mysql configuration my.cnf (windows version is my.ini), add the configuration:
sql_mode='NO_ENGINE_SUBSTITUTION
2. SQL statement modification
1) Execute sql first, check sql_mode
SELECT @@sql_mode;
My local query results are as follows:
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
2) Modify sql_mode, including existing libraries and new libraries, as follows:
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 sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Exception description When the company's old project code was started locally, mysql reported the following error: analyse problem However, the project deployed on the company's server does not have t...
Check SQL_MODE results returned by mysql8 Remove the only_full_group_by this SQL_Mode, the operation is as follows: Then execute the SQL statement will not report an error, this is just modifying SQL_...
1. Background My local mysql 8 executed a SQL error...
Remember once, when you migrate the service, connect to the new database, the database is also the backup of the previous, found an error: I started thinking that it was wrong when I imported i...
Now that you know the problem, you can modify this configuration, find the MySQL configuration file, and query the sql_mode field in the /etc/my.cnf file on the linux system. I did not find this keywo...
Questions are as follows: ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘jol.solution.nick’ which is not functionally depende...
MySql Query error [Err] 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 co...
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'XXX' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_m...
problem: the reason: solve:...
The specific errors are as follows: 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...