mysql为5.7之前,则会默认启用ONLY_FULL_GROUP_BY SQL模式,在该模式下MySQL查询非HAVING条件或ORDER BY聚合操作在查询的列没有在group by 中出现,就会出现该错误。
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'table.field' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by