I have two table application_requests and transactions in both the tables there may be matching record or may not be. For any condition i want record from both the tables.
In transactions table there is a foreign key column application_request_id (this has value of reference of primary key in application_requests table).. If this condition matched then it should display as one row (or record).
I dont know how to achieve this in laravel.
I have tried below codes but its not working:
$a = \DB::table('application_requests')->select('id');
$b = \DB::table('transactions')->select('application_request_id');
$results = $b->union($a)->get();
echo "<pre>";
print_r($results);die;
transactions table is
And my application_requests table is
just like that:
DB::table('transactions')->join('application_requests', 'transactions.application_request_id', '=', 'application_requests.id', 'full outer');
this is the right code to make a full join:
$second = DB::table('t1')
->rightJoin('t2', 't1.t2_id', '=', 't2.id')
$first = DB::table('t1')
->leftJoin('t2', 't1.t2_id', '=', 't2.id')
->union($first)
->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With