laravel eloquent Union query example
In this article, We will explain to you how to use the Union query in laravel. The laravel eloquent provides many types of eloquent methods. the Union method two queries combine and return the data.
So you can see below the following example.
1 2 3 4 5 6 | $student_1 = DB::table('students') ->select("students.first_name","students.last_name"); $student_2 = DB::table('standards') ->select("standards.name") ->union($student_1) ->get(); |
The unionAll method is also available and so same as the syntax of a union.
Please follow and like us: