diff --git a/queries.md b/queries.md index 939247be465..f87a99f9bef 100644 --- a/queries.md +++ b/queries.md @@ -232,14 +232,18 @@ The query builder may also be used to write join statements. To perform a basic ->select('users.*', 'contacts.phone', 'orders.price') ->get(); -#### Left Join Clause +#### Left Join / Right Join Clause -If you would like to perform a "left join" instead of an "inner join", use the `leftJoin` method. The `leftJoin` method has the same signature as the `join` method: +If you would like to perform a "left join" or "right join" instead of an "inner join", use the `leftJoin` or `rightJoin` methods. These methods have the same signature as the `join` method: $users = DB::table('users') ->leftJoin('posts', 'users.id', '=', 'posts.user_id') ->get(); + $users = DB::table('users') + ->rightJoin('posts', 'users.id', '=', 'posts.user_id') + ->get(); + #### Cross Join Clause To perform a "cross join" use the `crossJoin` method with the name of the table you wish to cross join to. Cross joins generate a cartesian product between the first table and the joined table: