Without knowing what your data looks like, the general syntax you need to insert into the select by attributes window is:
[FIELD_1] IS NULL OR [FIELD_2] IS NULL OR [FIELD_3] IS NULL
and so on for as many fields as you have to work with. For reference the full query would be:
SELECT * FROM [TABLE_NAME] WHERE [FIELD_1] IS NULL OR [FIELD_2] IS NULL OR [FIELD_3] IS NULL
Implemented the value maps of Edit Widget Property on one of Reservoirs layer. I have an attribute with type of reservoir (this water body could be Reservoir, Dam, Anicut or even null) and I had no problem with it.
Initially, I clicked on Load Data From Layer button and selected my layer from the Layer dropdown. Then selected type attribute for both Value and Description. The important thing was to check the Insert Null value on top checkbox. this will actually automatically add null values to the list.
After clicking Ok, I got the values as follows:
Then you will be able to select values from the dropdown with null values as well. had no problem changing from null to values and from values to null.
Here is a video of what I did, Gives a clear picture how I did it. :
https://youtu.be/qpJ9Etlop-Y
With reference to your further edits in question and with my 10 years of software development experience, the inference i could make from the Value Map is that it cannot be changed with respect to the insert statement that its making with null values. The tool has been programmed to insert the null values as string. Unless and until someone is capable of reprogramming the tools to their required needs, the null insertion cannot be changes. If i am wrong then someone can correct me. But there is an alternative.
As you mentioned you only need to display other values except NULLs in the select query statement, there is a workaround. what you need to do is to initially change the NULL as string to null through UPDATE statement and then execute your select query.
first run the insert statement and then execute the select query. then you will get the desired results as you mentioned.
Have recreated the situation with the data I have with reservoirs. Actually you need to implement update statement instead of insert. I inserted null values into reservoir database from the dropdown created using value maps. have a look at the two tables in the snapshot below:
Here is a query I ran after updating the null values from the dropdowns. you can notice that null values have been displayed for results section of the query for distinct values:
Then I updated the database using update statement like in the snapshot and then ran the sql statement for distinct values. Got the results like desired and like displayed in the figure below:
Change your sql statement like this:
UPDATE awrtracker.awr_tracker_sync SET threat_lvl=null where threat_lvl='NULL';
Best Answer
NULL
is not equal to an empty string.NULL
is by definition an "unknown value" of which we cannot assume anything. Whereas an empty string is a string without contents. You can test forNULL
by using"column_name" IS NULL
and for an empty string by using"column_name" = ''
Apparently in your data there are no
NULL
values but only empty strings.What you can do is
NULL
by using the field calculator with the expressionNULLIF("name", '')
(QGIS >= 3.6 required)"name"= ''
as selection criteria