geolocationpostgislatitude-longitude

PostGIS latitude longitude radius


I have two tables A and B:

I need to make a SQL query that selects all rows from A table inside the radius from B table.

Can somebody show me a SQL query example?


Solution

  • Probably you can do something like this:

    SELECT 
        a.*
        , b.id
    FROM
        a
    JOIN
        b
    ON
        ST_DWithin(b.point, ST_MakePoint(a.long, a.lat), b.radius)
    

    Take into account that: