[Qgis-user] Select by Expression: exclusive (not inclusive)

Thayer Young thayeray at yahoo.com
Wed Jul 7 07:49:55 PDT 2021


 Hi Bob, 
No, SQL does not care about capitalization, it is used for humans to read each others code. So I neglected to capitalize the OR, making it harder for you to read, but the interpreter should do just fine.
Python on the other hand cares very much about capitalization and white space. SQL does not care about white space either, so you can put extra spaces, tabs and carriage returns in your code.
-Thayer


    On Wednesday, July 7, 2021, 10:26:50 AM EDT, Basques, Bob (CI-StPaul) <bob.basques at ci.stpaul.mn.us> wrote:  
 
 
Not a Capitalization thing?
 
  
 
Bobb
 
  
 
  
 
From: Qgis-user <qgis-user-bounces at lists.osgeo.org> On Behalf Of Thayer Young
Sent: Wednesday, July 7, 2021 9:23 AM
To: qgis-user at lists.osgeo.org
Subject: [Qgis-user] Select by Expression: exclusive (not inclusive)
 
  
 
| 
Think Before You Click:This email originated outsideour organization.
  |


  
 
As Marco has explained, QGIS expressions are based on SQL which means that if you use a null containing field in a statement the nulls will be excluded from the query results unless you specifically state that they should be included. So you need to say:
 
  
 
"tag_service" IS NULL or "tag_service" NOT IN ('alley', 'drive-through', 'driveway', 'laneway','parking_aisle', 'parking')
 
  
 
-Thayer
 
 
 
  
 
From: Andrew Hughes <ahhughes at gmail.com>
 
To:Qgis-user at lists.osgeo.org
 
Subject: [Qgis-user] Select by Expression: exclusive (not inclusive)
 
Message-ID:
 
    <CAMvYC1Xs=YaXj6Os5vfnnNAV_v60TJCQBauT-YgDnuToc6koMw at mail.gmail.com>
 
Content-Type: text/plain; charset="utf-8"
 
  
 
Hi All,
 
  
 
I can't for the life of me figure out why I can't "Select all features that
 
are *NOT* an alley, drive-through, driveway.... "
 
  
 
I am trying to use "Select by Expression".
 
  
 
The attribute I am trying to filter with is called "tag_service" and has 77
 
distinct values, including NULL.
 
  
 
*Q: Why does this expression select nothing?*
 
  
 
*"tag_service" NOT IN ('alley', 'drive-through', 'driveway', 'laneway',
 
'parking_aisle', 'parking')*
 
  
 
  
 
Supplementary, the following does select records (but I want the above
 
expression to work):
 
  
 
*"tag_service" IS NULL or "tag_service" = "service"*
 
  
 
  
 
Help would be much appreciated,
 
  
 
Thank you
 
Andrew
 
  
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210707/0c41ae03/attachment.html>


More information about the Qgis-user mailing list