I have just one table of street segments of Berlin. I have a query that outputs all segments of category > 1, that are within a distance of 2000m of those segments which are of category 1.
This works fine:
SELECT DISTINCT s.id, s.geom FROM table s INNER JOIN table m ON ST_DWithin(s.geom, m.geom, 2000) WHERE m.category = 1 AND s.category > 1;
But now i want to exclude from the result set those segments of s that intersect with m. So i just appended the following expression:
... AND NOT ST_Intersects(s.geom, m.geom);
With this additional line the result set is the same as without, though i know there are segments that meet this condition. If i omit the 'NOT', asking for segments that DO intersect, i get about 400 segments. I also tried to use Disjoint, with the same problem.