MySQL 5.7版本sql_mode=only_full_group_by問題

MySQL 5.7中only_full_group_by這個模式是默認開啓mysql

 

解決方法一:執行SET GLOBAL sql_mode = ''; 把sql_mode 改爲非only_full_group_by模式。驗證是否生效 SELECT @@GLOBAL.sql_mode 或 SELECT @@sql_modesql

 或Mysql控制檯執行session

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

轉自:https://stackoverflow.com/questions/37619417/mysql5-7-upgrade-issue-group-by-incompatible-with-sql-mode-only-full-group-by函數

 

解決方法二:在my.cnf(mysql配置文件裏),添加spa

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

  

解決方法三:在sql查詢語句中不須要group by的字段上使用any_value()函數 code

相關文章
相關標籤/搜索