AnsweredAssumed Answered

Select By Query from Items in Python List

Question asked by mitchh300 on Oct 10, 2016
Latest reply on Oct 10, 2016 by chewentao

I'd like to create a SQL query statement which can select by multiple items in a Python string.  

 

Can this be done?

 

lyr = r''
my_list = ['12','13','14','15']

for i in my_list:      
    qry = "OBJECTID" + i

arcpy.SelectLayerByAttribute_management(lyr, qry)

 

The problem I'm having is formatting the list properly so it won't trip up the SQL statement.  Should I create a new list with the items separated by a "+" character?

Outcomes