24.2 C
New York
Wednesday, August 10, 2022

Example of unionAll in Query Builder Laravel

- Advertisement -





Sometimes you need to bind multimple query then you can use unionAll in laravel. If you use union all then laravel query builder provide unionAll method for mysql union. when you are doing big project or ERP level project then mostly you require to use union for getting data from database with multiple table. In Following example you can see how to use union all in Laravel 5.

Example:

$silver = DB::table("product_silver")

->select("product_silver.name"

,"product_silver.price"

,"product_silver.quantity");

$gold = DB::table("product_gold")

->select("product_gold.name"

,"product_gold.price"

,"product_gold.quantity")

->unionAll($silver)

->get();

print_r($gold);

- Advertisement -

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles