Working with PostgreSQL. I have a Table with streets (Linestrings), and a Table with accidents (Points). The streets are divided into sections. I want to find the accidents within 50m around a certain street. I used ST_Union to combine the Street segments to select a certain street, then made a Buffer around it, but when I try to select the accidents within the buffer QGIS crashes, guess there might be something wrong.
SELECT 1 as Id, c.accidents
ST_UNION (a.geom)
FROM Roads a, roads b, accidents c
WHERE a.roadname = 'A3'
AND st_distance (a.geom, b.geom) < 50
AND ST_Within (c.geom, ST_Buffer (a.geom, 50))
GROUP BY a.geom, c.accidents
ST_DWithin
operator. Use that instead. Also, multiple tables inFROM
is an ancient practice -- use aJOIN
operator. More details about the "crash" are necessary.