MySQL error: # 1 of ORDER BY clause is not in GROUP BY sql_mode = only_full_group_by

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

Intelligent Recommendation

Expression #1 of SELECT list is not in GROUP BY clause and xxxx sql_mode=only_full_group_by

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

MySQL uses group by error SQL_MODE = only_full_group_by modifies SQL_MODE in Session in Navicat

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

Mysql error sql_mode=only_full_group_by

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

MySQL sql_mode=only_full_group_by error

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

More Recommendation

columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by mysql8.0

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 error Expression # 1 of ORDER BY clause is not in GROUP BY

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

mysql group sql_mode=only_full_group_by issue

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

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

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

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

Top