5

Using QGIS in the operation 'select by expression' how is the correct expression to select multiple field value? ex. City NAME = ROME and NAPLES (expression is invalid)

  • 1
    do you mean OR instead of AND? – RutgerH Mar 17 '17 at 13:50
20

You can also use the SQL IN operator

"City Name" IN ('ROME','NAPLES')
  • Is it possible to do something similar but only stating part of the part of the words ? For example i would like to select all features containing 'RO' and 'PLES'. I tried IN but it doesn't works. I know that "City Name" LIKE '%RO%' OR "City Name" LIKE '%PLES%' works but the expression is a bit long... I would like something such as "City Name" LIKE ('%RO%','%PLES%'). – ZKB Nov 1 '15 at 15:29
5

Do you mean:

"City Name" = 'ROME' OR "City Name" = 'NAPLES' OR ....
  • Just formatted the code so that it's valid QGIS expression code. – Nathan W Nov 20 '13 at 22:50
  • 1
    This won't actually return any results. As the City Name can't both be ROME and Naples. You want an or here, or use flippinGeo's answer and use "IN". – Fezter Nov 21 '13 at 4:32
  • That's right, my mistake, you need to use OR, rather than AND – Ryan Garnett Nov 21 '13 at 5:03

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.