問題描述:
用到GROUP BY 語句查詢時com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'col_user_6.a.START_TIME' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with
解決辦法:
1、在數據庫查詢框查詢:
select @@global.sql_mode;
如果查詢結果爲:
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
2、解決辦法
a、如果是windows平臺安裝的數據庫,進入MySql安裝路徑下,打開my.ini文件;
b、如果是linux平臺,打開 /etc/my.cnf 文件
在文件的最末尾加上:
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
3、重啓mysql
查看版本:
方法一:status;
方法二:select version();
啓動:
service mysqld start (5.0版本是mysqld)
service mysql start (5.5.7版本是mysql)
停止:
service mysqld stop
重啓:
service mysqld restart