I am building a model that includes a 'select by attribute' algorithm, and I am attempting to select by multiple fields where the value matches a model input.

Essentially, I want the selection query to be 'field1 = input AND field2 = input'

Based off the tooltip, and this question (Select multiple fields in Modelbuilder) I believe that the syntax for selecting by multiple field parameters should be field1;field2:

enter image description here

However, this is not working for the select by attribute tool. The dialog box closes and clears the 'Selection attribute' field when I hit OK.

Is there a different syntax for the select by attribute tool or is this not possible? I am able to work around it for now by having two 'select by attribute' algorithms in the model and selecting within the current selection. I am using QGIS version 3.16.


You can't input two fields at once here with this function. The function select by attribute has only one possible input for the selection attribute when you run it standalone from the toolbox. So I guess it will not accept more inputs in the model as it is not designed for that.

The question you linked to has apparently the built in capacity to select more than one input fields as you can see from the optional plural form: Dissolve field(s) - and there, it really makes sense.

But with select by attribute, you have only the singular form: Selection attribute.

If you had two inputs field, QGIS would need an additional possibility to know how these two fields are combined: field_1 = School_Code AND field_2 = School_Code ? Or rather: (field_1 OR field_2) = School_Code?

So I guess your best option is to run select by attribute twice. Or you can try select by expression where you are free to define complex expressions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.