Laravel eloquent Union and Union all

This will show you how we can use union and union all queries in laravel 6 app.

Laravel eloquent provide query builder and they give us join, relationship, subquery and also union. But we need some time to get all records from two different table at that time you need to use union or union all query.

Here we will create two tables “table_a” and “table_b”

$results_a = DB::table("table_a")
 $results_b = DB::table("table_b")
   ->union($results_a )
 dd($results_b );

Leave a Reply

Close Menu