[GIS] QGIS Filters and Queries

filterqgisquery

In QGIS is there a way to filter a layer using the Query Builder to show all values which include a particular phrase. For example I have a list of organisations and I want to filter all those which include the word Wales. I can do this using the attribute table but not in the map view so that the map just shows these selected features.

Best Answer

Use "LIKE" with percentages.

In my shapefile of countries I can select any country with a name like "This and that" with:

"CNTRY_NAME" LIKE '% and %'

this selects only "Bosnia and Herzegovina". If I remove the spaces:

"CNTRY_NAME" LIKE '%and%'

I get Iceland, England and all the others with "and" in them.

That all works for shapefiles - the help for the query builder mentions that the syntax and behaviour may depend on your data source.

Related Question