Group by multiple columns in Laravel

前端 未结 4 687
小鲜肉
小鲜肉 2020-12-09 15:41

How to GROUP BY multiple column in Laravel? I tried this code:

$routes = DB::table(\'route\')
    ->groupBy(\'rte_origin\')
    ->groupBy(         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-09 16:01

    Put the select before the groupBy and the arguments in brackets.

    $routes = DB::table('route')
        ->select(['column_1', 'column_2'])
        ->groupBy(['column_1', 'column_2'])
        ->get();
    

提交回复
热议问题