I'm trying to create a subset of one layer which includes the geometries intersecting with the bbox of certain features of the same layer.
I tried to create a Virtual Layer in QGIS with the following statement:
SELECT * FROM layer WHERE st_intersects( ( SELECT st_envelope(geometry) FROM layer WHERE ID IN (1, 2, 3, 4) ), geometry )
The statement does not raise an error. The problem is, that it only gives back the geometries intersecting with the bbox of the feature with
ID = 1 although the IDs 1, 2, 3 & 4 are included in the
WHERE clause as list.
How would I need to change the query to include all the given IDs in the resulting subset?