QGIS Select by Expression – Select Multiple Attributes Containing Different Words

qgisselect-by-expression

I would like to select multiple attributes which contains some specific text ("Bus", "Car", and "Motorbike") from the same field ("commodity") using Select by Expression function in QGIS. My version is QGIS 3.24.0

In case I just want to select the attributes of field "commodity" which contains the text "Bus", I use like operator:

 "commodity" like '%Bus%'

However, I also want the rows which contains other words as "motorbike" and "car". Among other things, I am trying the following:

"commodity" like ('%Bus%', '%Motorbike%', '%Car%')

However, it does not work. Any idea of how I should proceed?

Best Answer

You need to chain your LIKE expression with the OR operator so your expression become :

"commodity" like '%Bus%' OR "commodity" like '%Motorbike%' OR "commodity" like '%Car%'

(Separating value with comma work for the IN operator but not with like)