MySQL question: SQL_MODE = ONLY_FULL_GROUP_BY

problem

ERROR: Expression #1 of SELECT list is not in GROUP BY clause 
and contains nonaggregated column 'xxx.sd.dic_cn_name' which 
is not functionally dependent on columns in GROUP BY clause; 
this is incompatible with sql_mode=only_full_group_by Error 
Code: 1055 

the reason

From the error message, it is necessary to putxxx.sd.dic_cn_nameThe field is placed in the group BY clause.
Error SQL:

SELECT
	sd.dic_cn_name as memberTypeCnName,
	sd.dic_en_name as memberTypeEnName,
	GROUP_CONCAT( cm.member_cn_name ) as castCnName,
	GROUP_CONCAT( cm.member_en_name ) as castEnName
FROM
	xxx.sn_movie_cast_members mcm,
	xxx.sn_cast_members cm,
	xxx.sn_system_dictionary sd
WHERE
	mcm.cast_members_id = cm.id AND
	sd.dic_code = mcm.member_type_code AND
	mcm.movie_id = 214
GROUP BY
	mcm.member_type_code;

Repaired SQL:

SELECT
	sd.dic_cn_name as memberTypeCnName,
	sd.dic_en_name as memberTypeEnName,
	GROUP_CONCAT( cm.member_cn_name ) as castCnName,
	GROUP_CONCAT( cm.member_en_name ) as castEnName
FROM
	xxx.sn_movie_cast_members mcm,
	xxx.sn_cast_members cm,
	xxx.sn_system_dictionary sd
WHERE
	mcm.cast_members_id = cm.id AND
	sd.dic_code = mcm.member_type_code AND
	mcm.movie_id = 214
GROUP BY
	mcm.member_type_code, sd.dic_cn_name, sd.dic_en_name;

Segments that will need to adddic_cn_namewithdic_en_name, Add the group by clause, you don't need to change the MySQL configuration.

reference

Intelligent Recommendation

mysql error this is incompatible with sql_mode = 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. ...

MYSQL: this is incompatible with sql_mode = only_full_group_by solution

Option One: Query the sql_mode of the current database search result Reset the value of sql_mode (requires root account) Finally, restart the database Option II: Find my.cnf result Add a sentence to t...

mysql 5.7 this is incompatible with sql_mode=only_full_group_by

vi /etc/my.cnf #Add the following content to the last line of the configuration file sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_...

MySQL sql_mode=only_full_group_by error (solved)

On database 5.7, only_full_group_by mode will be enabled by default, but after enabling this mode, the original group by statement will report an error. Cause Analysis: For group by aggregation operat...

More Recommendation

Mysql this is incompatible with sql_mode=only_full_group_by exception

The database was directly upgraded from version 5.5 to version 5.7, and an exception occurred when SQL was executed. After querying the official Myql documentation, it turns out that Mysql5.7 has modi...

The error of mysql sql_mode=only_full_group_by in mybatis.

I wrote an sql when using mybits in the project: It was correct when tested on a machine, but it was wrong when it was put on the server: This matter caused an error because some versions of mysql5.7 ...

mysql error: this is incompatible with sql_mode=only_full_group_by

Solution: modify the mysql configuration file The local server can modify this Add under [mysqld] Then restart service mysql restart  ...

Solve MySQL-sql_mode=only_full_group_by error

Specific error: [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...

MySql group error sql_mode=only_full_group_by

MySql reports an error sql_mode=only_full_group_by Prospect introduction problem solve Prospect introduction There is a long long ago project. As the purchased Alibaba Cloud database expired and no on...

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

Top