i tried the CakePHP 3.x \"Bookmaker Tutorial\" and i followed the instruction step by step. Unfortunately, at the end of the first chapter i get the attached error:
This is a new thing in MySQL 5.7 and is a warning that your query is ambiguous.
Consider the following table:
id | name | age | points
--------------------------------------------
1 Bob 21 1
2 James 14 1
3 Bob 21 3
4 James 14 2
5 Casey 17 3
If you did the following query:
SELECT name, age, SUM(points) FROM scores GROUP BY name
Then the name
column is used for grouping. Note that age
may have multiple values, so it's "non-aggregated". You need to do something to collapse down those values.
The behaviour in 5.6 and previous was to just pick the first one depending on sort order, though this was sometimes unpredictable and would fail. In 5.7 they're preventing you from doing it in the first place.
The solution here is to group on that as well, or to apply an aggregate operator like MIN()
to it.