Be careful using
SET sql_mode = ''
This actually clears all the modes currently enabled. If you don't want to mess with other settings, you'll want to do a
SELECT @@sql_mode
first, to get a comma-separated list of the modes enabled, then SET it to this list without the ONLY_FULL_GROUP_BY
option.