Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

Thanks, but this doesn't fit my need.

0

Alternative is DB::raw.

Since your advanced WHERE includes a possibility of a null, you can coalesce it to a value. Assuming '123'..

.. $join->on('A.id', '=', 'B.a_id') ->orWhere(DB::raw('COALESCE(A.b_stuff,"123")','=','123');

Or maybe reconsider how you join?

0

Thanks. Never heard talk about COALESCE. It solve my problem.

But because, I want to go futher if I need, is there a way to make more complex join or not?

0

@Grummfy,

Yep, you can specify more complex join conditions, see docs on query builder

0

@Xum thanks. But the complex part is a bit too simple. Like I say in my example, I have tried, but nobody has able to give me a solution to my example. Except by changing it to something simpler (so it's solve my issue but it doesn't answer to my question) .

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Grummfy grummfy Joined 27 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.