<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SelectLayerByAttribute_management not selecting anything in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426233#M33464</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What back-end is your EGDB?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 31 Aug 2019 15:22:52 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-08-31T15:22:52Z</dc:date>
    <item>
      <title>SelectLayerByAttribute_management not selecting anything</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426231#M33462</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've read through most of the other similar questions and nothing so far has addressed my issue; most are about syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddFieldDelimiters&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tempFeatureLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BLDG_ID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" LIKE '{0}%'"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;county&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tempFeatureLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; expression&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tempFeatureLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DeleteRows_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tempFeatureLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's an SDE Database feature class, if that makes a difference.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tried rewriting the expression as below with the same result:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""" "BLDG_ID" LIKE '37019%'"""&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;expression &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BLDG_ID LIKE '37019%'"&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:11:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426231#M33462</guid>
      <dc:creator>JohnLay</dc:creator>
      <dc:date>2021-12-11T19:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management not selecting anything</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426232#M33463</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/12213"&gt;John,&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your&amp;nbsp;BLDG_ID attribute, is it text or numeric in the SDE database? &amp;nbsp;What about the table?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it is numeric in your SDE database, LIKE with text wildcards will only work on a text value in select by attribute statement.&amp;nbsp; You can use a CAST statement to change BLDG_ID to a character string then use the LIKE statement with text wildcards such as&amp;nbsp; &lt;STRONG&gt;"CAST(BLDG_ID AS CHARACTER(10))&amp;nbsp;LIKE '37019%'"&lt;/STRONG&gt;. &amp;nbsp;Make sure to include a large enough&amp;nbsp;character size by changing the "10" to what you need.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Aug 2019 01:59:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426232#M33463</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2019-08-31T01:59:19Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management not selecting anything</title>
      <link>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426233#M33464</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What back-end is your EGDB?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Aug 2019 15:22:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/selectlayerbyattribute-management-not-selecting/m-p/426233#M33464</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-08-31T15:22:52Z</dc:date>
    </item>
  </channel>
</rss>

