I have two layers in QGIS, each one with a field called "Name"
. I need to select the features in 'layer2' whose name exists in 'layer1' (totally or partially).
For example, in the images below, I want the following features in layer2 (on the right) to be selected: 197, 198, 200, 201, 203, 204, and 206.
How can I do that?
Best Answer
Use "Select by expression" with this expresstion on layer 1:
Explanation: The function
aggregate()
creates an array of all values of the field"name1"
in the layer namedpoints1
.array_contains()
checks if the value (content, string) of each feature on layer 2 in the field"name2"
is contained in this array and in this case returnstrue
, otherwisefalse
.