(1055, "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'XX' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by")mysql
MySQL 5.7和up實現了對功能依賴的檢測。若是啓用了only_full_group_by SQL模式(在默認狀況下是這樣),那麼MySQL就會拒絕選擇列表、條件或順序列表引用的查詢,這些查詢將引用組中未命名的非聚合列,而不是在功能上依賴於它們sql
解決方法一:session
取消/etc/my.cnf裏的sql_modethis
解決方法二:(親測有效)spa
# 一、 mysql> 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';
# 二、 mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
# 三、 set @@sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
感謝!https://blog.csdn.net/chai1230/article/details/89514482.net