Skip to content

Commit 9678846

Browse files
authored
Merge pull request #4913 from GeraldPK/5.7
[5.7] Add rightJoin to Query Builder Docs
2 parents 8315239 + 613ec06 commit 9678846

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

queries.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,18 @@ The query builder may also be used to write join statements. To perform a basic
232232
->select('users.*', 'contacts.phone', 'orders.price')
233233
->get();
234234

235-
#### Left Join Clause
235+
#### Left Join / Right Join Clause
236236

237-
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:
237+
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:
238238

239239
$users = DB::table('users')
240240
->leftJoin('posts', 'users.id', '=', 'posts.user_id')
241241
->get();
242242

243+
$users = DB::table('users')
244+
->rightJoin('posts', 'users.id', '=', 'posts.user_id')
245+
->get();
246+
243247
#### Cross Join Clause
244248

245249
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:

0 commit comments

Comments
 (0)