tags: mysql only_full_group_by
mysql5.7 + version is turned on by defaultonly_full_group_byMode,When you turn on this mode, the column must query conditions are grouped. The original group by statement will be reported this error.
select @@global.sql_mode;
result:
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
We can see that the first one isonly_full_group_by
1:RemoveONLY_FULL_GROUP_BY, Reset the value.
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';
2:() Function using any_value
SELECT
any_value (ID) AS ID,
any_value(PIC_TYPE),
PIC_NAME
FROM
`cp_picname_mapping` g
GROUP BY
g.PIC_NAME
Action: After the completion of packet, the same column together
select GROUP_CONCAT(
s.name SEPARATOR ';'
) as names FROM student s GROUP BY s.class_id
Students grouped by class, take out all the names make up names, with each student's name;No split.
select GROUP_CONCAT(
CONCAT(age,':'),
s.name SEPARATOR ';'
) FROM student s GROUP BY s.class_id
Compared with the above query, more than aCONCAT()Function, the name of each student's age and put a piece, with:Dividing, by a plurality of;No split.
Another reference example
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...
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...
Some errors encountered when using MySQL 1. Err1055, this problem occurs often when performing a SQL statement, there will be this problem in the last line. Solution: In the /etc/my.cnf (linux) file, ...
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...
Solve and analyze mysql error: this is incompatible with sql_mode = only_full_group_by When developing a timing task, I forgot to change the configuration (think of it yourself), causing a waste of ti...
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...
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...
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....