Mysql Query "this is incompatible with sql_mode = only_full_group_by" error

tags: MySQL  group by  

problem

When deploying a server-deployed server, the original SQL statement has appeared "this is incompatible with sql_mode = only_full_group_by" error.

reason

After mysql5.7.5, the default opens ONLY_FULL_GROUP_BY, so some of the previous SQL cannot be executed normally. The problem is that the SQL statement is not specified. Some results after group BY are uncertain, and this type of error will be found.

ONLY_FULL_GROUP_BY semantics isAll columns in Select Target List are clear semanticsSimply put, in this mode, the value in the target list is from the results of the aggregate function (SUM, AVG, MAX, etc.), or it comes from the value of the expression in Group By LIST.

Solution

existSELECTThe following results plus the Any_Value function, ignore the uncertainty of the address value in each name group and accept the query. like:

# before fixing
SELECT name,mobile FROM person
WHERE code='020'
group by time;

# After modification
SELECT ANY_VALUE(name),ANY_VALUE(mobile) FROM person
WHERE code='020'
group by time;

Of course, it is best to solve the return value uncertain problem, not ignore. . .

Intelligent Recommendation

Mysql: MySQL-this is incompatible with sql_mode=only_full_group_by error resolution

First, the background Previously used local server in development, local is mysql5.6, there is a problem when switching to online server Prompt MySQL-this is incompatible with sql_mode=only_full_group...

MySQL-this is incompatible with sql_mode=only_full_group_by error solution

MAMP MySql configuration file path under Mac /Applications/MAMP/tmp/mysql/my.cnf First, the principle level You need to modify the mysql configuration file to force the specified ONLY_FULL_GROUP_BY at...

MySQL-this is incompatible with sql_mode = only_full_group_by Error Resolution

MySQL-this is incompatible with sql_mode = only_full_group_by Error Resolution Edit Profile Linux in: my.cnf In Windows: my.ini Add a line at the bottom Mysql restart the service to address Note: Usin...

Resolved: mysql error: 1055 - this is incompatible with sql_mode = only_full_group_by

mysql query error: [Err] 1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'tase1.ai.home_url' which is not functionally dependent on columns in GROUP BY ...

More Recommendation

MySQL error [Err] 1055 ... this is incompatible with sql_mode = only_full_group_by

Problem Description After upgrading MySQL version is 8.0.12, there is a problem. When you create a data table, or perform updates, error [Err] 1055 ... The following error message: [Err] 1055 - Expres...

Mysql execute statement error this is incompatible with sql_mode=only_full_group_by

Error output: [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 depende...

Solve mysql report this is incompatible with sql_mode=only_full_group_by error

Baidu found most of the two solutions, generally recommend the following one, I use it and solve the problem. add the following line at the end of mysql my.ini file...

mysql error: this is incompatible with sql_mode=only_full_group_by solution

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

MySQL- this is incompatible with sql_mode=only_full_group_by error solution

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

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

Top