AnsweredAssumed Answered

SelectLayerByAttribute_management not selecting anything

Question asked by jplay on Aug 28, 2019
Latest reply on Aug 31, 2019 by bixb0012

I've read through most of the other similar questions and nothing so far has addressed my issue; most are about syntax.

 

I'm trying to select by attribute from a Feature Layer. But every time, Arc announces that it succeeded and nothing is selected. It works just fine using the same expression to select from a Table View. Any ideas?

 

expression = arcpy.AddFieldDelimiters(tempFeatureLayer, "BLDG_ID") + " LIKE '{0}%'".format(county)

arcpy.SelectLayerByAttribute_management(tempFeatureLayer, "NEW_SELECTION", expression)
if int(arcpy.GetCount_management(tempFeatureLayer)[0]) > 0:
    arcpy.DeleteRows_management(tempFeatureLayer)

 

It's an SDE Database feature class, if that makes a difference.

 

I've also tried rewriting the expression as below with the same result:

 

expression = """ "BLDG_ID" LIKE '37019%'"""

and

expression = "BLDG_ID LIKE '37019%'"

Outcomes