cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
This post is from one of our customers!

Looking forward to that free shirt! In the mean time, here's a fun sql snippet I wrote to find select users (for something I was working on) by radius of area:
SELECT
    location.id,location.name,location.address,count(distinct user.id) as user,
    (
        6371 * acos(
            cos( radians( your.latitude )) *
            cos( radians( location.lat )) *
            cos( radians( location.lat ) - radians( your.longtitude )) +
            sin( radians( your.latitude )) *
            sin( radians( location.long ))
        )
    ) `distance`
FROM
    location LEFT JOIN user ON location.id=user.location_id
GROUP BY
location.id
HAVING
    `distance` < 100
ORDER BY
    `distance`
LIMIT
    25
Rate this article:
Version history
Last update:
‎03-02-2023 08:58 AM
Updated by:
Contributors