Laravel group by


DB::table(ā€˜table_nameā€™)->groupBy(ā€˜column_nameā€™)->get(); is used for group by condition in laravel.


laravel group by clause Example

We are going to fetch data with groupBy clause in laravel from the table emp.

DB::table('emp')->groupBy('manager_name')->get();

Will Generate the following query.

//Select * from emp group BY ā€˜manage_nameā€™ ;


Advertisements

Add Comment

šŸ“– Read More