Closed
Description
I have a query that return the cities on a fixed distance from a point:
$query->addSelect(DB::Raw(
'(3959 * acos (
cos ( radians('.$lat.') )
* cos( radians( lat ) )
* cos( radians( lon ) - radians('.$lon.') )
+ sin ( radians('.$lat.') )
* sin( radians( lat ) )
)) AS distance'))
->having('distance', '<', 300)->paginate(10);
This cause this mysql error:
Column not found: 1054 Unknown column 'distance' in 'having clause'
Because the agregate query generated by the pagination class contain the having but not the select (distance)
select count(*) as aggregate from `cities` where `id` > 0 having `distance` < 300
Metadata
Metadata
Assignees
Labels
No labels