mysql 5.7.X sql_mode - only_full_group_by

 項目由開發環境 提測到 測試環境,報如下錯誤:

[Err] 1055 - Expression #1 of ORDER BY clause is not 
in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ'
 which is not functionally dependent on columns in GROUP BY clause; 
this is incompatible with sql_mode=only_full_group_by

 

Mysql的5.7.x版本中默認是開啓sql_mode = only_full_group_by
而在這個模式下,我們使用分組查詢時,出現在select字段後面的只能是group by後面的分組字段,或使用聚合函數包裹着的字段

 

解決方法:去掉 only_full_group_by

// 查詢有哪些模式
select @@global.sql_mode;


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`;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章