I'm getting the following error from my PHP application:
Incorrect SQL query (Database) In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'db_20172201.cm_order.buyer'; this is incompatible with sql_mode=only_full_group_by
After looking around for a while, and after trying to identify the query that gave this error I decided that I should change the SQL_MODE option in my MySQL server.
I did 2 things to accomplish this:
executed this query
SET SESSION sql_mode = 'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Added the following in
my.cnf
which is the configuration file for MySQL[mysqld] sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
I thought that these to would be enough but the error never goes away from my application.
When I check for the value of SQL_MODE
in my environment by this query
SELECT @@GLOBAL.sql_mode
it shows the values inserted above.
I don't know where else to look. I also tried to set the sql_mode variable from my application before executing a query but doesn't solve.
--- UPDATE
I just printed in my application the result of the query SELECT @@SESSION.SQL_MODE
and it turns out to be as I set it:
array(1) { [0]=> object(stdClass)#5 (1)
{
["@@SESSION.sql_mode"] => string(118) "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
}
}
But I still get the error
PS. MySQL version is 5.7.18