Navicat client to perform the update using the update statement error [Err] 1055 - Expression # 1 of ORDER BY clause is not in GROUP BY

[Introduction] Environmental
  System environment: Tencent cloud + 5.7.18 + Navicat 11.2.7 (client)

 

[Description] case

Morning update statement execution error analysis:

Use Navicat 11.2.7 version performs error
UPDATE shx_xxx.user_xxx SET roxx_id = 'xxxxxxxxxxxxxxxxxx0001' WHERE usxx_id = 'xxxxxxxxxxxxxxxxxx35';

报错信息:
[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

 

[Analysis]

Check error message prompts only_full_group_by, the error is typically when used in a query, a simple update statement and conditions with no group by order by statement, rather strange

View sql_mode explained:
ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES, the NO_ZERO_IN_DATE, the NO_ZERO_DATE, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION
ONLY_FULL_GROUP_BY parameters for the new version of MySQL 5.7.4: For GROUP BY aggregate operations, if a column in the SELECT, does not appear in a GROUP BY, then the SQL is not legitimate, because the column is not in the GROUP BY clause;

But the normal use workbench tools update, universal tracking log (general_log), have found that the use of query information_schema.PROFILING operation on update, the SQL view consumption information recording executed, the query does not meet ONLY_FULL_GROUP_BY parameter limit, thus giving rise to an error

Show Variables like '% Gen%';
SET Global general_log =. 1;
Update XXXXX SET XXXX;
SET Global general_log = 0;
Show Variables like '% Gen%'; "" "observe must close the parameter, or a large amount of log information

2020-01-08T15:20:47.934694+08:00 2605922 Query SHOW GLOBAL STATUS
2020-01-08T15:20:48.837771+08:00 2608143 Query SET PROFILING=1
2020-01-08T15:20:48.840037+08:00 2608143 Query SHOW STATUS
2020-01-08T15:20:48.845610+08:00 2608143 Query SHOW STATUS
2020-01-08T15:20:48.853304+08:00 2608143 Query UPDATE shx_xxx.user_xxx SET roxx_id='xxxxxxxxxxxxxxxxxx0001' WHERE usxx_id='xxxxxxxxxxxxxxxxxx35';
2020-01-08T15:20:48.857803+08:00 2608143 Query SHOW STATUS
2020-01-08T15:20:48.863344+08:00 2608143 Query SELECT QUERY_ID, SUM(DURATION) AS SUM_DURATION FROM INFORMATION_SCHEMA.PROFILING GROUP BY QUERY_ID
2020-01-08T15:20:48.867054+08:00 2608143 Query SELECT STATE AS `状态`, ROUND(SUM(DURATION),7) AS `期间`, CONCAT(ROUND(SUM(DURATION)/0.000846*100,3), '%') AS `百分比`
FROM INFORMATION_SCHEMA.PROFILING WHERE QUERY_ID=39 GROUP BY STATE ORDER BY SEQ

 

 

【to sum up】

Use Navicat 11.2.7 version execution error, use Navicat 12.1.8 properly, use workbench tools to work properly, it is recommended to use the new version of Navicat, workbench, SQLyog tool.

Of course, the parameters can be modified in accordance with sql_mode avoid, but the only_full_group_by features of SQL standardized wording similar to Oracle's SQL statement written, there are no special requirements (business can not modify the SQL script) is not recommended to modify the parameters of circumvention operation;

Guess you like

Origin www.cnblogs.com/zetanchen/p/12167437.html