How can I solve incompatible with sql_mode=only_full_group_by in laravel eloquent?

前端 未结 12 1707
不思量自难忘°
不思量自难忘° 2020-11-29 11:09

My laravel eloquent is like this :

$products = Product::where(\'status\', 1)
            ->where(\'stock\', \'>\', 0)
            ->where(\'category         


        
12条回答
  •  爱一瞬间的悲伤
    2020-11-29 11:24

    That's because latest versions of MySQL behave like most dbms already do regarding group by clauses; the general rule is

    if you're using group by, all columns in your select must be either present in the group by or aggregated by an aggregation function (sum, count, avg and so on)

    Your current query is grouping by store_id, but since you're selecting everything the rule above is not respected.

提交回复
热议问题