1Inner Join : ->join('contacts', 'users.id', '=', 'contacts.user_id')
2Left Join : ->leftJoin('posts', 'users.id', '=', 'posts.user_id')
3Right Join : ->rightJoin('posts', 'users.id', '=', 'posts.user_id')
4Cross Join : ->crossJoin('colors')
5
6Advance Queries :
7-----------------
8 ->join('contacts', function ($join) {
9 $join->on('users.id', '=', 'contacts.user_id')
10 ->where('contacts.user_id', '>', 5);
11 })
12
1use Illuminate\Support\Facades\DB;
2
3class UserController extends Controller
4{
5 public function index()
6 {
7 $users = DB::table('users')->select('id','name','email')->get();
8
9 return view('some-view')->with('users', $users);
10 }
11}
12
1DB::table('users')
2 ->where('name', '=', 'John')
3 ->where(function ($query) {
4 $query->where('votes', '>', 100)
5 ->orWhere('title', '=', 'Admin');
6 })
7 ->get();