Please use the “IN” operador

Please use the “IN” operador


It’s not the first time I see people that, to select feature by their fields values, use expressions like this:

"field" = 'value1' OR "field" = 'value2' OR "field" = 'value3' [OR ...]

A more practical and pretty way of doing this is by using the IN operator instead.

"field" IN ('value1','value2','value3'[,...])

This operator is available in almost every GIS software I know. In QGIS, it can be used even if there isn’t a small little button to click.
Captura de tela 2014-04-23 16.50.40

In fact, this is an abbreviation of what is used in SQL, where the operator is used in the WHERE statement:

FROM parks
WHERE "tipo" IN ('PI','CM','PJ');

2 thoughts on “Please use the “IN” operador

  1. Excelente tutorial. Muito bom mesmo. Sou iniciante em SQL e estou pensando em montar um e-book sobre queries aplicadas em Geotecnologias. Com certeza vai facilitar a vida de muitas pessoas.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s