AnsweredAssumed Answered

Select Layer by Attribute in ArcPy

Question asked by nikfal on Apr 10, 2018
Latest reply on Apr 10, 2018 by rvburton

I am working on a simple application. The user can choose either Numeric values or string values to select (i.e. valName). However if you write the where clause like this:

arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", FieldName + opName + "'" + valName + "'")

It doesn't work for numbers and if you write like this:

arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION",FieldName + opName + valName)

  It doesn't work for strings. 

 

Any simple solution without if condition?

Outcomes