1. Principle level
This error occurred in the MYSQL 5.7 version and above.
The default SQL configuration of MySQL 5.7 is: sql_mode = "only_full_group_by", which strictly executes the "SQL92 standard".
When it is upgraded from 5.6 to 5.7, most of them will choose to adjust the SQL_mode for grammar compatibility, so that it is consistent with 5.6, in order to be as compatible as possible.
2. SQL level
When SQL is executed, this reason occurs:
Simply put: the result of the output is target list, which is the field followed by select, and there is a place in a place by column, which is the place
The field followed by group by. Because the settings of only_full_group_by, if a field is not on the target list
If it appears at the same time as the GROUP BY field, or the value of the polymerization function, then this SQL query is considered illegal by mysql and reports errors.
1. View the sentence of SQL_MODE as follows
select @@GLOBAL.sql_mode;
Solution- (Recommended solution 2)
① Solution 1: SQL statement temporarily modify sql_mode
| 1 |
|
(Note: After setting, you may need to restart the MySQL service, and then set it again, because it will fail after the restart)
After restarting the MySQL database service, only_full_group_by will still appear.
② Solution 2: Perfect solution.
Add this sentence to the My.CNF file:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Just restart mysql.
Notice:
If you have not used my.cnf, you must manually create a My.CNF directory under the few directory we saw in the previous one. Usually /usr/local/Mysql/support-files/my-default.cnf directory There will be a default file below. If you copy it to the specified location for custom modification, it is OK.
But sometimes/usr/local/mysql/support-filesWithout the files we want, it can only be added by itself.
Download my.cnf address:MySQL and MariaDB Configuration File template (my.cnf/my.ini) | FromDual
grateful:
"This is incompative with sql_mode = only_full_group_by" error solution - -Blog Garden
MySQL and MariaDB Configuration File template (my.cnf/my.ini) | FromDual
1. Problem description: Use mysql 5.7.21 to execute the following statement: select u.login_name loginName,u.user_name userName,s.student_user_id userId, s.student_code studentCode,tc.schedule_class_n...
For record, my local computer mysql version is 8.0.19, which is almost a relatively new version. Query database version statement: select VERSION() The following error will appear when using the GROUP...
Project scene: Sometimes, I encountered database duplicate data, you need to group data and take it out to show it, then you need to use the Group by statement. However, if mysql is a high version, wh...
Execute SQL reported this question: this is incompatible with sql_mode=only_full_group_by Reason for problems: The result of the output is called Target List, which is the field followed by SELECT, as...
This is the error screenshot Cause: MySQL version problem MySQL 5.7.5 above versions have achieved detection of functional dependence. If you enable the only_full_group_by SQL mode (default), mysql wi...
Project scene: When the project needs to be printed, use a polymerization query and related query, and report an error during the inquiry Problem Description Query error Expression #6 of SELECT list i...
Project scene: Run this SQL script error with DBeaver today script: Problem description: sql_mode = only_full_group_by Reason analysis: MySQL8.x version defaults to open onLY_FULL_GROUP_BY The officia...
Mysql installed with Docker installed on the Linux service has an error prompt: mysql execute an error: Error querying database. Cause: java.sql.SQLSyntaxErrorException:which is not functionally depen...
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column ‘XXXX’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with...
1. Problem description SQL query statistics abnormal 2. Analysis of the cause The literal understanding is the limitation of sql_model = only_full_group_by, which causes SQL that can be checked normal...