mysql5.7執行sql語句報錯:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonagg


mysql5.7執行sql語句報錯:In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'yunva_changke.u.user_id'; this is incompatible with sql_mode=only_full_group_by


1.方法1,需要重啟mysql服務


編輯/etc/my.cnf文件,加入如下參數,重啟mysql
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"


2.方法2,不需要重啟mysql服務


可以看到模式為only_full_group_by
mysql>show variables like '%sql_mode';

mysql> show session variables like '%sql_mode%';
mysql> show global variables like '%sql_mode%';


使當前會話失效
mysql> set global sql_mode='';
mysql> set session sql_mode='';


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM