Tuesday, April 11, 2017

Incompatible with sql_mode=only_full_group_by Permanent solution


If a query has aggregate functions and no GROUP BY clause, it cannot have nonaggregated columns in the 

select list, HAVING condition, or ORDER BY list with ONLY_FULL_GROUP_BY enabled.

Some people try this for disable it but it's not good at all.
This is not good.
SET sql_mode = ''
Better solution is blew code.

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
The permanent  solution

We open the configuration file we decided on before (/etc/mysql/my.cnf) and add the following line into the [mysqld]section


sql_mode = "STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
Save, exit, and restart MySQL

No comments:

Post a Comment

Total Pageviews