使用mysql group by 报错

问题:通过 GROUP BY 查询时抛出下列异常

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #19 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.s.download_add' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

解决方法:

  • 1.在my.cnf中加入sql_model = ""
sudo vim /etc/my.cnf
  • 2.重启mysql
    启动MySql服务:
    sudo /usr/local/mysql/support-files/mysql.server start

    停止MySql服务:
    sudo /usr/local/mysql/support-files/mysql.server stop

    重启MySql服务:
    sudo /usr/local/mysql/support-files/mysql.server restart

你可能感兴趣的:(使用mysql group by 报错)