Trying to get near by, but the ci4 not working pagination with slect as (...)
$builder = $this->builder();
$builder->join('branches','services_providers.sid = branches.serviceProvider');
$builder->join('branches_categories','branches.sid = branches_categories.branch');
$builder->select('services_providers.*, ((ACOS(SIN('.$latitude.' * PI() / 180) * SIN(branches.latitude * PI() / 180) + COS('.$latitude.' * PI() / 180) * COS(branches.latitude * PI() / 180) * COS(('.$longitude.' - branches.longitude) * PI() / 180)) * 180 / PI()) * 60 * 1.1515 * 1.609344) as distance');
$builder->having('distance > 50');
$builder->paginate(20);
Goth this error: Unknown column 'distance' in 'having clause
If I used findAll() instead of paginate it's work fine.