MySQL query statistics report errors This is incompative with sql_mode = only_full_group_by

tags: Even small sails can be available away  mysql  sql  database  java  spring

1. Problem description

SQL query statistics abnormal

SELECT 	t.username,
		t.police_no,
		SUM(t.totalflytime) AS totalTime
	
FROM trackname t
WHERE t.delete_state = 1 AND t.police_no IS NOT NULL
GROUP BY t.police_no

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'feidun.t.username' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

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 normally in the previous MySQL version.
Reference document:
http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-setting
The document points out: only_full_group_by settings will not allow query fields to include non -gathering columns

3. Solution

(1) Upgrade MySQL version
(2) Complete the non -gathering column you want to query in Group By, that is, if the column [non -function] in query query in query should be in group by
SQL correct example:

SELECT 	t.username,
		t.police_no,
		SUM(t.totalflytime) AS totalTime
	
FROM 	test t
WHERE t.delete_state = 1 AND t.police_no IS NOT NULL
GROUP BY t.police_no,t.username

Intelligent Recommendation

MySQL uses group by to report an error sql_mode=only_full_group_by

mysql opens only_full_group_by mode. In this mode, using the old version of mysql to get group by group data will report an error, the error is as follows: `Expression #3 of SELECT list is not in GROU...

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 data query error: sql_mode=only_full_group_by

Today, the project changed its system, reinstalled the MySQL database, and the data was reported incorrectly when the function was executed. Because there is no problem before changing the system, che...

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

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

One article completely explains that mysql is reported to 1055 -Select list is not in group by incompative with sql_mode = only_full_group_by

Talk about conclusions first The root cause of this problem is caused by the rigorous SQL. Because there is no strict restrictions before the 5.7 version, there is no error, but after 5.7, the default...

More Recommendation

MySQL does not require group by field query to avoid errors to report onLY_FULL_GROUP_BY

Is there any way to query the fields that do not need aggregate? For example, many people come up and select * from xxx group by xx; Or add a field that you want to check more Basically, you can repor...

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 this is incompatible with sql_mode=only_full_group_by

MySQL reasonable set of sql_mode sql model used to solve the following types of problems (1) By setting sql mode, can perform different stringency data check, data preparation of effective protection....

mysql incompatible with sql_mode=only_full_group_by

Solution my.cnf adds a piece of data sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION   service mysqld restart resta...

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

Top