-1

I have many points in a table. I want to show points near one point. Buffer area can be 10 or 100 in SQL Server using SQL query.

  • 1
    Welcome to GIS SE. As a new user, please take the Tour, which explains how our "Focused question/Best answer" model operates. All coding questions are expected to contain code. Please Edit the question to contain your best effort and give an indication of the error you are receiving. – Vince May 30 '19 at 10:22
1

You will need to have a unique identifier column in your table. Here I called it id, and also refer to the table as my_table. I also assume that the point of interest has an id of 1

/* Get the point of interest's geometry and save it in a common table expression */
WITH point_of_interest AS (
    SELECT
        geom
    FROM
        my_table
    WHERE
        id = 1
)

/* Select everything from all the other points if they are within 100m */
SELECT
    mt.*
FROM
    my_table AS mt,
    point_of_interest AS poi
WHERE
    id != 1 -- Don't return the point of interest itself
    AND
    ST_DWithin(poi.geom, mt.geom, 100) -- Return only the points within 100 m
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.