mysql5.7 group by語法 1055

先來看以下語句,查詢默認存在的引擎表mysql

 以前使用的MySQL版本爲5.7如下,根據support進行分組執行語句以下sql

添加跟分組support無關的字段engineoracle

 

沒有任何問題this

如今使用的版本是5.7spa

以後根據support進行分組以後orm

1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'information_schema.ENGINES.ENGINE' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_byblog

意思是it

SELECT list不在GROUP BY子句中,而且包含非聚合列'information_schema. engine。在功能上不依賴於GROUP BY子句中的列;這與sql_mode=only_full_group_by不兼容io

也就是select展現的列必須跟group by相關function

這就跟oracle的group by語法一致了,不得不說,更合理些,固然了,一些查看語句應該就會複雜些

查看系統變量sql.mode 

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

修改方式,window編輯my.ini,Linux編輯my.cnf,將[mysqld]中的sql_mode的值刪除ONLY_FULL_GROUP_BY,重啓解決!

相關文章
相關標籤/搜索