I'd like to create a SQL query statement which can select by multiple items in a Python string.
Can this be done?
lyr <SPAN class="operator token">=</SPAN> r<SPAN class="string token">''</SPAN>
my_list <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'12'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'13'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'14'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'15'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> my_list<SPAN class="punctuation token">:</SPAN>
qry <SPAN class="operator token">=</SPAN> <SPAN class="string token">"OBJECTID"</SPAN> <SPAN class="operator token">+</SPAN> i
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">,</SPAN> qry<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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?