Forespørgslen bruger den syntaks, der er specifik for MySql. I Postgres (og alle andre kendte for mig RDBMS) skal du bruge en afledt tabel:
select *
from (
select *,
(3959 * acos( cos( radians(53.49) ) * cos( radians( places.lat ) )
* cos( radians( places.lng ) - radians(-2.38) )
+ sin( radians(53.49) ) * sin( radians( places.lat ) ) ) ) AS distance
from (
select *
from places
where places.lat between 53.475527714192 and 53.504472285808
and places.lng between -2.4043246788967 and -2.3556753211033
) as places
where places.deleted_at is null
) sub
where distance <= $1
order by distance asc
Jeg har også fjernet citater fra numeriske konstanter.