Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

From the Laravel docs: Unions - http://laravel.com/docs/queries#unions

 $first = DB::table('users')->whereNull('first_name');
 $users = DB::table('users')->whereNull('last_name')->union($first)->get();

Obviously the query builder will have to be altered to match your SELECT and WHERE statements, but the UNION would be the same.

Last updated 2 years ago.
0

$second= DB::table('brands') ->select('brand_id') ->where('parent_id','=',$id); $first = DB::table('goods') ->select('goods_id', 'name', 'img', 'anons', 'price', 'hits', 'new', 'sale') ->where('visible','=','1') ->whereIn('goods_brandid', [$second]); $products =DB::table('goods') ->select('goods_id', 'name', 'img', 'anons', 'price', 'hits', 'new', 'sale') ->where('goods_brandid', '=', $id) ->where('visible','=','1') ->union($first)->get();

is it right?

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

neolinks neolinks Joined 12 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.