Skip to content

Instantly share code, notes, and snippets.

@jonnybarnes
Created October 10, 2015 15:52
Show Gist options
  • Save jonnybarnes/ff1042d60b7a9130dd81 to your computer and use it in GitHub Desktop.
Save jonnybarnes/ff1042d60b7a9130dd81 to your computer and use it in GitHub Desktop.
Postgres syntax error
ERROR: missing FROM-clause entry for table "places" at character 639
STATEMENT: 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
) sub where "places"."deleted_at" is null having "distance" <= $1 order by "distance" asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment