So, I updated my ubuntu box and mysql came along for the ride to the glorious 5.7 that brings about doom:
[:error] [pid 9211] [client 0.0.0.0:1] PHP Fatal error:
Uncaught PDOException: SQLSTATE[42000]: Syntax error or access violation:
1140 In aggregated query without GROUP BY, expression #1 of SELECT list contains
nonaggregated column 'a.Z'; this is incompatible with sql_mode=only_full_group_by
The line it's referring to is:
$s = $d->prepare("SELECT a.Z,a.Y,a.X,MAX(b.F) as `G` FROM `a`,`b` WHERE (a.P=:va1 && b.R:va2)");
Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns.
source: http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sqlmode_only_full_group_by
So, here are my 4 questions:
1- nonaggregated columns being a.Z
, a.Y
, a.X
?
2- functionally dependent on = ?
3- uniquely determined by. Literarily, columns that are (for example) P_Id int NOT NULL UNIQUE
?
4- Even though this error I can fix with adding any_value()
around a.Z
, a.Y
and a.X
I still don't understand why I'm doing so.
I imagine that the alternative would be to do a group by a.Z
or/and a.Y
or/and a.X
. But which of those 3 do I pick in the group by and why?
Also, I do not want to disable only_full_group_by
. I would like to understand how to properly fix this current issue and most likely the astronomic number that will follow.