N
N
Nikolay2020-08-25 13:40:46
Laravel
Nikolay, 2020-08-25 13:40:46

How to add an AND condition to leftJoin?

Good day!

I don't understand how to use the construction of the form:

SELECT *
  FROM table1 AS t1
    LEFT JOIN table2 as t2
      ON t1.a = t2.b
    LEFT JOIN table3 AS t2
      ON t1.a = t3.b
      AND t2.a = t3.c
WHERE t1.d = 7

The documentation only describes orOneither where:

DB::table('users')
  ->join('contacts', function ($join) {
      $join->on('users.id', '=', 'contacts.user_id')->orOn(...);
  })
  ->get()


PS ->and(...) ->andOn(...) Tried - does not work :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-08-25
@iNickolay

where instead of orOn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question