美文网首页php
使用mysql group by 报错

使用mysql group by 报错

作者: 左木北鱼 | 来源:发表于2019-08-17 11:41 被阅读0次

    问题:通过 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 报错

        本文链接:https://www.haomeiwen.com/subject/rsmhsctx.html