Skip to content

Instantly share code, notes, and snippets.

@jamiepittock
Created September 27, 2012 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiepittock/3792933 to your computer and use it in GitHub Desktop.
Save jamiepittock/3792933 to your computer and use it in GitHub Desktop.
SELECT ct.entry_id, ct.title, ct.url_title, cd.field_id_344 as cf_places_latitude, cd.field_id_345 as cf_places_longitude, ROUND( '3959' * acos( cos( radians('51.494737') ) * cos( radians( cd.field_id_344 ) ) * cos( radians( cd.field_id_345 ) - radians('-0.146358') ) + sin( radians('51.494737') ) * sin( radians( cd.field_id_344 ) ) ), '2' ) AS distance
FROM exp_channel_data as cd
LEFT JOIN exp_channel_titles as ct ON ct.entry_id = cd.entry_id
WHERE ct.channel_id IN ('2')
AND ct.entry_id != '12'
HAVING distance < '1'
ORDER BY distance desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment