Answers for "query builder in laravel 8 join"

PHP
4

laravel query builder join

use Illuminate\Support\Facades\DB;

$users = DB::table('users')
            ->join('contacts', 'users.id', '=', 'contacts.user_id')
            ->join('orders', 'users.id', '=', 'orders.user_id')
            ->select('users.*', 'contacts.phone', 'orders.price')
            ->get();
Posted by: Guest on December-09-2020
0

Laravel 8 query builder, Left Join / Right Join Clause

//Left join
$users = DB::table('users')
            ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
            ->get();
//Right join
$users = DB::table('users')
            ->rightJoin('posts', 'users.id', '=', 'posts.user_id')
            ->get();
Posted by: Guest on August-06-2021

Code answers related to "query builder in laravel 8 join"

Browse Popular Code Answers by Language