jeudi 31 mai 2018

QueryException error for laravel Query builder

i have added a query builder code for laravel api page

    DB::table('nearbies')
    ->select(DB::raw('( 6371 * acos ( cos ( radians(9.955308) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(76.302331) )+ sin ( radians(9.955308) ) * sin( radians( latitude ) ))) AS distance,id,name,location'))
  ->havingRaw('distance < 10')
->orderBy('distance','asc')

But while running its showing error

QueryExceptionSQLSTATE[42000]: Syntax error or access violation: 1463 Non-grouping field 'distance' is used in HAVING clause (SQL: select ( 6371 * acos ( cos ( radians(9.955308) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(76.302331) )+ sin ( radians(9.955308) ) * sin( radians( latitude ) ))) AS distance,id,name,location from `nearbies` having distance &lt; 10 order by `distance` asc



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Jn6vvL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire