下載安裝的是最新版的mysql5.7.x版本,默認是開啓了 only_full_group_by
模式的,但開啓這個模式後,原先的 group by
語句就報錯,而後又把它移除了。mysql
一旦開啓 only_full_group_by
,感受,group by
將變成和 distinct
同樣,只能獲取受到其影響的字段信息,沒法和其餘未受其影響的字段共存,這樣,group by
的功能將變得十分狹窄了sql
only_full_group_by
模式開啓比較好。數據庫
由於在 mysql
中有一個函數: any_value(field)
容許,非分組字段的出現(和關閉 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_bythis
select @@global.sql_mode;spa
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_SUBSTITUTIONcode
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';orm