[GIS] Using QGIS to Select by Expression

expressionqgissql

A basic QGIS 2.2.0-Valmiera, Select By Expression – Field Calculator question.

Introduction

I am a geologist searching through a geological database (see attached figure). I have a shapefile and associated attribute file of which I would like to select certain records within a field to make as new shapefile layer.

Task/method

I wish to search the 'GEOLHIST' and select Permian lithologies using the field calculator. Subsequently I shall Save Selection As. I have tried using the following script unsuccessfully.

"GEOLHIST" 
  IS 'Early Carboniferous to Early Permian' 
  OR 'Early Permian' 
  OR 'Early Permian to Late Carboniferous' 
  OR 'Early Permian to Late Permian' 
  OR 'Late Carboniferous to Early Permian' 
  OR 'Late Carboniferous to Permian' 
  OR 'Late Permian' 
  OR 'Late Permian to Permian' 'Permian' 
  OR 'Permian to Early Permian'

Question

What script can I use to select the above records?

Discussion

'GEOLHIST' IS 'Permian'

This script works. I have looked at the other OPERATORS (AND OR IS LIKE) and CONDITIONALS and have not figured out how to achieve my task.

Geological Attribute Table

@Nathan provided a working script, see attached figure.

I was not aware of the SQL operator in or the method of bracketing. This technique will be most helpful in the future.

"GEOLHIST" IN 
(
    'Carboniferous to Early Permian'
    , 'Early Permian'
    , 'Early Permian to Late Carboniferous'
    , 'Early Permian to Late Permian'
    , 'Late Carboniferous to Early Permian'
    , 'Permian'
    , 'Permian to Early Permian'
)

GEOLHIST SQL for multiple record success

Best Answer

If there is only need to select 'all permian lithologies' and no other conditions - you can use syntax like this:

"GEOLHIST" LIKE '%Permian%'

This should select all occurencess of 'Permian' word. This will not work with 'permian' probably. But you can change to '%ermian' thought.

Related Question