This query seems to work perfect on my older machine. However, on my new machine with MySQL 5.7.14 and PHP 5.6.25 it seems to throw an error:
Fatal er
Its a little late but I just ran into this error.
This command might be useful for anyone else who runs into the same error
mysql > SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
More information about this can be found at Table Plus and other links quoted above by JNevill.
Hope it helps someone else.