jpedder

SelectLayerByAttribute using an 'in' argument

Discussion created by jpedder on Apr 10, 2013
Latest reply on Apr 10, 2013 by jpedder
I'm trying to build a dynamic query that addresses user section of multiple values.

example: User input might be 1 or 1,2,3 or 1-5

I thought I could build a query such as

myfield = arcpy.AddFieldDelimiters(layer,"Number")

value = code to create an create an input list()
>>> value
[1, 2, 3, 4, 5, 6]

iQuery = '{0} in {1}'.format(value,myfield)

arcpy.SelectLayerByAttribute_management(layer,"NEW_SELECTION",iQuery)



Getting an 'Invalid expression Failed' error

Am I barking up the wrong tree with my methodology?

Thanks

Outcomes