I have a feature layer
in a gdb
. It has an attribute named uniqueid
. Some of rows have a value for uniqueid
and some do not. I am trying to select only the features that have a value (are not blank).
Using the Select by Attributes
dialog box, I am trying to create an expression that will weed out the blank features. I tried using where: unique IS NOT NULL
but that selected everything, both the features with a value and those that were blank. I then tried using Get Unique Values
and chose '', which was one of the options. It through an error. What am I doing wrong here? How can I select just the features that have a value for the uniqueid
attribute field?
Here's the actual text version of the error as requested:
There was a problem selecting
An invalid SQL statement was used. An invalid SQL statement was used.[fottprint_cslf_union_20181004] An invalid SQL statement was used.[SELECT OBJECTID FROM footprint_cslf_union_20181004 WHERE uniqueid IS NOT '']
2 Answers 2
The IS NOT syntax can only be used with null but you have a '' (an empty string value delimited by quote) so the correct syntax should be uniqueid <> ''
I think this is because your field is a text field where null/none/empty value are stored as empty string (thus the '' in the value selector), in a numeric field you get "real" null value and could use the uniqueid IS NOT null
syntax
-
OK, this turned out to be the correct answer. For whatever reason,
uniqueid <> ''
did not work originally. Maybe I was adding a space in the quotes. Whatever the reason, I shot down arcMap and restarted and it magically worked. I popped the same statement in aarcpy.selectByAttribute_management(...)
function and it worked. Thanks.gwydion93– gwydion932018年10月08日 00:19:55 +00:00Commented Oct 8, 2018 at 0:19
You can try to use the Wildcard "%" to Select By Attributes.
By using the Wildcard to form a statement that should contain characters that all the attributes should have you can select the Attributes that are not ''.
The syntax would be:
uniqueid LIKE '%CA%'
Or if CA is not common to all the attributes, try a numerical attribute value:
uniqueid LIKE '%0%'
You may need to string a few of these together to cover all your bases / potential combinations:
uniqueid LIKE '%0%' OR uniqueid LIKE '%1%' OR uniqueid LIKE '%CA%'
Depending on the values in the uniqueid field.
Explore related questions
See similar questions with these tags.
*column* IS NOT ''
. Part of your issue may be thatUNIQUE
is a reserved word in SQL, so there may be an alias to an actual column nameunique_
.