Expression #2 of SELECT list is not in GROUP BY clause and contains
nonaggregated column ‘a.id’ which is not functionally
dependent on columns in GROUP BY clause; this is incompatible with
sql_mode=only_full_group_bysql
MySQL 5.7.5及以上功能依賴檢測功能。若是啓用了ONLY_FULL_GROUP_BY SQL模式(默認狀況下),MySQL將拒絕選擇列表,HAVING條件或ORDER BY列表的查詢引用在GROUP BY子句中既未命名的非集合列,也不在功能上依賴於它們。(5.7.5以前,MySQL沒有檢測到功能依賴關係,默認狀況下不啓用ONLY_FULL_GROUP_BY。有關5.7.5以前的行爲的說明,請參見「MySQL 5.6參考手冊」。)this
select @@global.sql_mode
結果爲code
ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
執行it
set @@global.sql_mode =’STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION’;
成功解決io