here is my code
$products = DB::table('post_data')
->select('*')
->selectRaw('( 6371 * acos( cos( radians(?) ) *
cos( radians( latitude ) )
* cos( radians( longitude ) - radians(?)
) + sin( radians(?) ) *
sin( radians( latitude ) ) )
) AS distance', [$latitude, $longitude, $latitude])
->havingRaw("distance < ?", [$radius])
->get();
echo "<pre>";
print_r($products); die;
it gives an error
Syntax error or access violation: 1463 Non-grouping field 'distance' is used in HAVING clause (SQL: select *, ( 6371 * acos( cos( radians(41.118491) ) * cos( radians( latitude ) )
post_data
having distance < 5)if i'm not use having then it shows the results but this query runs in database
using laravel 5.4
please help me
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community