问题描述:
用到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