For Exercise 1.2.1 in the QGIS Training Manual Training Manual Link I attempted to extract data from multipolygon layer using the query;

building != 'NULL'

I had double checked if there were features with no information in their 'building' field in my data and there were many. Unfortunately the query failed with message shown in image below.

Query Failed

I have tried to exclude spaces, replacing != with NOT, different data, and using " " instead of "NULL"

As I am a bit of a rookie with coding, I have been having no luck.

No luck with Kazuhito Answer, "building" != 'NULL'. This query isn't selecting any features, please see photos for reference.

Feature count in layer Query result

  • 2
    SQL 101: Don't compare against NULL, test for it: fieldname IS NULL
    – Vince
    Jan 6, 2018 at 0:13
  • Your syntax seems working perfectly to me. Please see my edit to see if I understand you correctly.
    – Kazuhito
    Jan 8, 2018 at 4:11
  • I've found a post in which this is discussed in gorgeous detail: gis.stackexchange.com/questions/203463/… Jan 8, 2018 at 12:40

1 Answer 1


Good catch! I have to wonder why NULL is inside double-quotation marks in the linked Training Manual. (Just a typo, maybe. Associated image shows single-quotations.)

Please try with single-quotation marks:

"building" != 'NULL'

About the error message: because QGIS thinks "xxx" is a field name, it tried to find a fieldname NULL and failed.

Thanks for your feedback. From your added images I feel your query syntax has been successful.

At the same time, I think I understand what you mean by This query isn't selecting any features... and you are right about that point.

Query Builder filters the objects according to your query, which means it just hides objects which do not meat your condition. In other words, it does not select any object... it simply displays them.

Hope the above clarifies the situation. If you need to select them, please try select (features) by expression tool through the Field Calculator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.