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

前端 未结 12 1700
不思量自难忘°
不思量自难忘° 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:48

    To select only aggregated columns, use the one of the raw methods provided by Laravel. For example:

    Product::selectRaw('store_id')
            ->where('status', 1)
            ->groupBy('store_id')
            ->get();
    

提交回复
热议问题