0
Hello, I am using Laravel and need to make a select in a table, also create a field that brings the result of a function.
my select is like this:
return \DB::table("view_pins_ocorrencias")
->select("*", "round(geo({$dados->latitude},{$dados->longitude},latitude_ocorrencia,longitude_ocorrencia),2) as distancia")
->havingRaw('distancia < 400')
->havingRaw('distancia > 0.3')
->get();
but it presents an error:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'round(geo(float(-46.544233),float(-23.543453),latitude_ocorrencia,longitude_ocorrencia),2)' in 'field list' (SQL: select *, `round(geo(float(-46`.`544233),float(-23`.`543453),latitude_ocorrencia,longitude_ocorrencia),2)` as `distancia` from `view_pins_ocorrencias` having distancia < 400 and distancia > 0.3)"
Basically it adds ` (Apostrophe) to the float, getting -14`. `xxxxxxx and also does it in Round. with that select does not work. I copied this query and took the ` then the bank presents the results without problem.
Unfortunately he presented the same result =/, but thanks anyway.
– Eduardo Dos Santos
Strange try to give a
DD(select)
and see if the string is being mounted correctly– Mateus
Yes, by doing the DD($select) it showed correctly. only by calling the function even it changes.
– Eduardo Dos Santos