Join Multiple Table Query in Laravel

Friends, today I will tell you this through my article. How you can join Multiple tables through laravel.

Join multiple tables Using laravel 7, join multiple tables query in laravel 6, laravel 5.8 Use join query for multiple table, join multiple tables query in laravel 5.7, join multiple tables query in laravel 5.6 Or 5.5 Or 5.4 and 5.3, 5.2, 5.1

If you want to join multiple table by laravel query. Then you can join table very easily. How to join multiple table by laravel below. The query of join is given below.

$join = DB::table('shares')
->join('users', 'users.id', '=', 'shares.user_id')
->join('comments', 'comments.user_id', '=', 'users.id')
->get();

Join multile tables query use with WHERE Condition

$join = DB::table('shares')
->join('users', 'users.id', '=', 'shares.user_id')
->join('comments', 'comments.user_id', '=', 'users.id')
->where('comments.comment_id', '=', 10)
->get();

Join two tables query use with Limit Condition

$join = DB::table('shares')
->join('users', 'users.id', '=', 'shares.user_id')
->join('comments', 'comments.user_id', '=', 'users.id')
->where('comments.comment_id', '=', 10)
->limit(5)
->get();