0
I have this error in my consultation, I have identified that the use of whereBetween
within a function
join
is impossible to use, but I saw that the staff was able to use the DB::Raw
and replace that whereBetween
.
The point is I haven’t found any examples of using DB::Raw
within a function
join
and the ways I tried were not successful.
Code:
$exec = DB::table('execucao_acompanhamento as a')
->join('execucao_acompanhamento_busca_bens as h', function($join)
use($data_busca_1_1, $data_busca_1_2){
$join->on('a.id','=','h.acompanhamento_id')
->where('h.busca_bens_id','=','1')
->whereBetween('h.data_busca', ["$data_busca_1_1","$data_busca_1_2"]);
})
->get();
See this: https://stackoverflow.com/a/37298384/1518921
– Guilherme Nascimento
So, as I want to compare between a period, wherein does not help me in this case, because wherein checks inside an array if in that table there is the value 1 and 10 for example, but in my case I have to check if there are values within the range 1 and 10.
– Luiz Gustavo Costa Ceolin
Luiz I understand, but the idea is not to use it exactly like this, but rather understand how he used raw and adapted, so you adjust and adapt to your case, understand? I can’t tell if it’ll work for you, but if I can test your code I’ll try to see if there’s a way to create an alternative.
– Guilherme Nascimento
Right, but in this example he used raw only for a Raw, as far as I know, it is not possible to use a between inside a raw. Or is it possible? I tried some form here and did not succeed.
– Luiz Gustavo Costa Ceolin