Answers for "join three tables in mysql laravel"

PHP
11

join 2 tables laravel

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

how to join two tables in laravel

use Illuminate\Support\Facades\DB;
//in the following example we will join two tables
//a products table and categories table
$categoryProducts = Product::join('categories', 'categories.id', '=', 'products.category_id')
        ->select('products.*', 'categories.category_name')
        ->where('products.status', 1)
        ->get();
Posted by: Guest on May-22-2022

Code answers related to "join three tables in mysql laravel"

Browse Popular Code Answers by Language