Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
錯內容
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre
原因分析
mysql 5.7預設啟用ONLY_FULL_GROUP_BY特性,即:對於GROUP BY聚合操作,如果在SELECT中的列,沒有在GROUP BY中出現,那麼這個SQL是不合法的,因為列不在GROUP BY從句中,也就是說查出來的列必須在group by後面出現否則就會報錯,或者這個欄位出現在聚合函式裡面。
解決方法
在mysql的配置檔案的最後強制設定sql_mode,把預設的ONLY_FULL_GROUP_BY去掉。
預設的sql_mode:(java專案fhadmin.cn)
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
修改mysql的配置檔案,在檔案最底部加上:
[mysqld]
[mysqld]
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後生效。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31558068/viewspace-2868539/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql報錯:Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggreMySqlExpressAI
- list is not in GROUP BY clause and contains nonaggre的問題AI
- [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains 的問題 MySQLExpressAIMySql
- [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated cExpressAI
- mysql主給備賦予許可權時報錯,MySQL [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clauseMySqlExpress
- [Developer] ORA-00979:not a group by expressionDeveloperExpress
- ORA-00979: not a GROUP BY expression報錯處理Express
- POXPOEPO Supplier Contact Field List Of Values Contains No EntriesAI
- 00017: Data frame has at least one annotation group that is enabled and contains graphicsASTAI
- SQL改寫的方法,select group by sumSQL
- C# 有關List<T>的Contains與Equals方法C#AI
- List中對比Contains, Exists, Any之間的優缺點AI
- Oracle Model ClauseOracle
- About Oracle WITH clauseOracle
- ANALYZE INDEX clauseIndex
- MySQL SELECT list is not in...MySQL關閉嚴格模式MySql模式
- Oracle SQL Model ClauseOracleSQL
- oracle全文索引之SECTION GROUP_1_NULL_SECTION_GROUPOracle索引Null
- select count(*)和select count(1)的區別
- Expression BlendExpress
- JavaScript contains()JavaScriptAI
- jQuery :contains()jQueryAI
- ALTER SESSION ADVISE ClauseSession
- ALTER SYSTEM DISCONNECT SESSION ClauseSession
- mysql select欄位別名 不可以在select 或者where中使用 但是group by 與order by可以使用MySql
- 1.基本select(筆記)筆記
- ACM Arithmetic ExpressionACMExpress
- Expression Date FunctionsExpressFunction
- [CareerCup] 5.4 Explain Expression ((n & (n-1)) == 0) 解釋表示式AIExpress
- jQuery.contains()jQueryAI
- javascript contains方法JavaScriptAI
- 列表:list[1],切片list[1:3],追加insert,修改,刪除remove,del,pop,查詢index,統計count,清空list.clear() 翻轉list.reverse(),...REMIndex
- VS Could not evaluate expressionExpress
- 通過建立動態型別 動態構建Expression Select表示式來控制Property可見性型別Express
- mybatis註解Select查詢List,返回有物件個數,但是為nullMyBatis物件Null
- 優化select count(*) from t1優化
- SQL入門之1 select 聯接SQL
- sga contains infomation (71)AI