1

I just want to know that which join will be used behind the scenes in Laravel join(). Either it is leftjoin(), rightjoin() or innerjoin() ?

For example:

What join will be used here actually?

$friends_votes = DB::table('users')
    ->join('votes', 'votes.user_id', '=', 'users.id')
    ->where('votes.user_id',1);
Kaleem Shoukat
  • 811
  • 6
  • 14
  • Does this answer your question? [How do I get the query builder to output its raw SQL query as a string?](https://stackoverflow.com/questions/18236294/how-do-i-get-the-query-builder-to-output-its-raw-sql-query-as-a-string) – Nico Haase Apr 15 '21 at 09:30
  • No, i'm asking about join() of laravel that what will be used behind the scenes by laravel. – Kaleem Shoukat Apr 15 '21 at 09:37
  • 1
    What does that mean? There's only a single `join` method in Laravel. Why not start a debugger to check that? – Nico Haase Apr 15 '21 at 09:50
  • I tried debugger and that was helpful, thank you! – Kaleem Shoukat Apr 16 '21 at 06:52

1 Answers1

3

innerJoin see laravel doc:

and if you want left or right join, you should strictly use them:

rightJoin:

$friends_votes = DB::table('users')
    ->rightJoin('votes', 'votes.user_id', '=', 'users.id')

leftJoin:

$friends_votes = DB::table('users')
    ->leftJoin('votes', 'votes.user_id', '=', 'users.id')
OMR
  • 11,736
  • 5
  • 20
  • 35