[Qgis-user] Select by Expression with Subquery

Martin Bain Martin.Bain at lismore.nsw.gov.au
Mon Jun 17 17:16:44 PDT 2019


Hi Randy,
This might work in QGIS 3 - it's untested because I'm currently on a machine with QGIS 2.18 (where the @parent variable is unavailable)

aggregate( 'LAYER2','count',"NAME","NAME"=attribute(@parent, 'NAME')) > 0

The other way might be to create a join to your target layer and then select the rows where the value of joined column is not null.

Cheers,
Martin.

From: Qgis-user [mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Altergott, Randy (CCI-Southwest)
Sent: Tuesday, 18 June 2019 3:41 AM
To: qgis-user at lists.osgeo.org
Subject: [Qgis-user] Select by Expression with Subquery

Hi QGIS users,
I'm new to QGIS and this is my first question.
Can I use QGIS "Select by Expression" to select all features in a vector layer where the "name" field value is also found within another layer (delimited text layer with no geometry)? I get a syntax error when using the following SQL.

"NAME" IN (SELECT "NAME" FROM 'LAYER2')

I'm using the "Map Layers" menu to add the layer name, so it actually displays something like 'LAYER2_ca36271a_8ec7_4aa7_a36c_67418104f66c' instead of just 'LAYER2'.

Thanks,
Randy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20190618/e88bd4c2/attachment.html>


More information about the Qgis-user mailing list