<?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: Select Layer By Attribute in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271251#M20977</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arcpy comes with a handy function called &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/addfielddelimiters.htm"&gt;AddFieldDelimiters &lt;/A&gt;to alleviate these SQL syntax errors - it encloses your field name properly within quotes, brackets, or none depending on the data source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 12 Sep 2016 18:03:20 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2016-09-12T18:03:20Z</dc:date>
    <item>
      <title>Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271245#M20971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following code snippet:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("dissBuffs_lyr", "NEW_SELECTION", '[sumPoint_2] &amp;gt; 1')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Where dissBuffs_lyr is a layer which has been converted from a feature class stored within a File Geodatabase with a variety of attributes one of which is sumPoint_2. I've tried so many variations of '[sumPoint_2] &amp;gt; 1' that I'm running out of ideas does anyone have any idea what I might be doing wrong?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 14:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271245#M20971</guid>
      <dc:creator>JohnWall</dc:creator>
      <dc:date>2016-09-12T14:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271246#M20972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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; &lt;SPAN class="string token"&gt;'"sumPoint_2" &amp;gt; 1'&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you are trying to select from a file geodatabase and not a full RDMS, you cannot put the field name in brackets. &amp;nbsp;They need to be in quotes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 15:07:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271246#M20972</guid>
      <dc:creator>AlexanderBrown5</dc:creator>
      <dc:date>2016-09-12T15:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271247#M20973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Alex,&lt;/P&gt;&lt;P&gt;I entered:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("dissBuffs_lyr", "NEW_SELECTION", '"sumPoint_2" &amp;gt; 1')&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;and got:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Python27\ArcGISx6410.3\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript&lt;BR /&gt; exec codeObject in __main__.__dict__&lt;BR /&gt; File "C:\gis\hpboyce02\tools\hydropath\part03a_minPoints_troubleshoot.py", line 56, in &amp;lt;module&amp;gt;&lt;BR /&gt; arcpy.SelectLayerByAttribute_management("dissBuffs_lyr", "NEW_SELECTION", '"sumPoint_2" &amp;gt; 1')&lt;BR /&gt; File "C:\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 7221, in SelectLayerByAttribute&lt;BR /&gt; raise e&lt;BR /&gt;ExecuteError: ERROR 000358: Invalid expression&lt;BR /&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;-John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 15:22:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271247#M20973</guid>
      <dc:creator>JohnWall</dc:creator>
      <dc:date>2016-09-12T15:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271248#M20974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you running the code snippet directly in the Python window in ArcMap or as a stand a lone script? &amp;nbsp;You are going to need the full path to the dissBuffs_lyr if you are not running it in the ArcMap python window.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;You can try this as well (Only if your field is an integer):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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; &lt;SPAN class="string token"&gt;"sumPoint_2 &amp;gt; 2"&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are running it in ArcMap (can you paste the additional messages shown below the console window). &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;ERROR &lt;SPAN class="number token"&gt;000358&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; Invalid expression
An invalid SQL statement was used&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
An invalid SQL statement was used&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;dissBuffs_lyr&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
An invalid SQL statement was used&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;SELECT OBJECTID FROM dissBuffs_lyr WHERE &lt;SPAN class="string token"&gt;'sumPoint_2'&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
Failed to execute &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;SelectLayerByAttribute&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;
Failed at Mon Sep &lt;SPAN class="number token"&gt;12&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;11&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;31&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;55&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2016&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Elapsed Time&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0.01&lt;/SPAN&gt; seconds‍‍‍‍‍‍&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:15:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271248#M20974</guid>
      <dc:creator>AlexanderBrown5</dc:creator>
      <dc:date>2021-12-11T13:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271249#M20975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Alex,&lt;/P&gt;&lt;P&gt;I am running the code within PythonWin as a standalone Python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was under the impression that I did not need to provide the path name if I created the layer within the same script (see below). Am I incorrect?&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;dissBuffs = "C:/gis/area/data/fgd.gdb/dissBuffs"&lt;/P&gt;&lt;P&gt;arcpy.MakeFeatureLayer_management(dissBuffs, "dissBuffs_lyr")&lt;BR /&gt;arcpy.AddJoin_management("dissBuffs_lyr", "OBJECTID", sumPoints, "OBJECTID", "KEEP_COMMON")&lt;BR /&gt;arcpy.CopyFeatures_management("dissBuffs_lyr", "jointedcountpolys.shp")&lt;BR /&gt;arcpy.SelectLayerByAttribute_management("dissBuffs_lyr", "NEW_SELECTION", "sumPoint_2 &amp;gt; 2")&lt;BR /&gt;arcpy.CopyFeatures_management("dissBuffs_lyr", correctPolys)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;EM&gt;"sumPoint_2 &amp;gt; 2"&lt;/EM&gt;&amp;nbsp;and still got the same result.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 16:14:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271249#M20975</guid>
      <dc:creator>JohnWall</dc:creator>
      <dc:date>2016-09-12T16:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271250#M20976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your code snippet above helps a lot, there are a few&amp;nbsp;items I would like to point out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Properly setting your workspace:&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/environments/current-workspace.htm" style="color: #2989c5;" title="http://desktop.arcgis.com/en/arcmap/latest/tools/environments/current-workspace.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Current Workspace (Environment setting)—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 1&lt;/STRONG&gt; (without setting workspace and exporting a shapefile):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="" style="color: #999999;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900;"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900;"&gt;"C:/gis/area/data/jointedcountpolys.shp"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;)&lt;/SPAN&gt;‍‍&lt;SPAN class="" style="border-right: 1px solid #999999; padding-top: 1em;"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Example 2&lt;/STRONG&gt; (set workspace to a folder, export shapefile):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.498039);"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900;"&gt;"C:/gis/area/data"&lt;/SPAN&gt;‍‍‍
arcpy&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="" style="color: #999999;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900;"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900;"&gt;"jointedcountpolys.shp"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="" style="border-right: 1px solid #999999; padding-top: 1em;"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Example 3&lt;/STRONG&gt; (set workspace to file geodatabase, export to feature class):&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.498039);"&gt;=&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900;"&gt;"C:/gis/area/data/fgd.gdb"&lt;/SPAN&gt;‍‍‍
arcpy&lt;SPAN class="" style="color: #999999;"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="" style="color: #999999;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900;"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;,&lt;/SPAN&gt; &lt;SPAN class="" style="color: #669900;"&gt;"jointedcountpolys"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999;"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍&lt;SPAN class="" style="border-right: 1px solid #999999; padding-top: 1em;"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Learning to set proper workspaces will be beneficial if you have more complex code that will run loops or iterate over various datasets. &amp;nbsp;You do not have to specifically reference the full path if you have preset variables already identified. &amp;nbsp;Although, utilizing workspaces is better practice when working with arcpy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to use the variable name &lt;STRONG&gt;correctPolys&amp;nbsp;&lt;/STRONG&gt;without quotes, it needs to be declared as a variable before CopyFeatures.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 4&lt;/STRONG&gt; (utilizing declared correctPolys variable name, set to feature class):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;correctPolys &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:/gis/area/data/fgd.gdb/correctPolys"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; correctPolys&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you can&amp;nbsp;put quotes around "correctPolys", but you need to declare your workspace first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example 5&lt;/STRONG&gt; (declare workspace, utilize quotes around output feature class name):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:/gis/area/data/fgd.gdb"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"correctPolys"&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a test&amp;nbsp;feature class in a file geodatabase called "dissBuffs" and added the sumPoints_2 field as integer. &amp;nbsp;I also populated the sumPoints_2 field with dummy data. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know when you populate sumPoint_2, you have a join to a table or feature class called sumPoints. &amp;nbsp;I was able to successfully run this on my test version:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:/gis/area/data/fgd.gdb"&lt;/SPAN&gt;
dissBuffs &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"C:/gis/area/data/fgd.gdb/dissBuffs"&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dissBuffs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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; &lt;SPAN class="string token"&gt;"sumPoint_2 &amp;gt; 1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"correctPolys"&lt;/SPAN&gt;&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That should output correctPolys into your a&amp;nbsp;geodatabase; assuming the sumPoint_2 filed is already populated. &amp;nbsp;I want to try and isolate your problems with the selection using select&amp;nbsp;by attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If sumPoint_2 is not populated, can you add some test data and run my last snippet to see if it works?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271250#M20976</guid>
      <dc:creator>AlexanderBrown5</dc:creator>
      <dc:date>2021-12-11T13:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271251#M20977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Arcpy comes with a handy function called &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/addfielddelimiters.htm"&gt;AddFieldDelimiters &lt;/A&gt;to alleviate these SQL syntax errors - it encloses your field name properly within quotes, brackets, or none depending on the data source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Sep 2016 18:03:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271251#M20977</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-09-12T18:03:20Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271252#M20978</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/19932" target="_blank"&gt;Darren Wiens&lt;/A&gt;&amp;nbsp; Completely forgot about AddFieldDelimiters! &amp;nbsp;Thanks for mentioning.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As Darren pointed out, you can just set your SQL&amp;nbsp;expression, and reference as a variable in the SelectLayerByAttribute_management.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;sql_exp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{0} &amp;gt; {1}"""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation 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;dissBuffs&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"sumPoint_2"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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; sql_exp&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;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;This would ensure that no matter where you pulled the data from, it would be formatted properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:15:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271252#M20978</guid>
      <dc:creator>AlexanderBrown5</dc:creator>
      <dc:date>2021-12-11T13:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271253#M20979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Alex,&lt;/P&gt;&lt;P&gt;I have posted a similar type question to the GeoNet today but since this is in the same vein I figured I would ask you directly. This doesn't answer the question about selecting features by attribute though, especially when joined in-memory...is it not possible? What is the "full path" you recommend to a feature layer in memory...is that a thing?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 19:39:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271253#M20979</guid>
      <dc:creator>DerekNelson</dc:creator>
      <dc:date>2017-12-14T19:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271254#M20980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Derek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The SQL at the end of the SelectLayerByAttribute_management call is where you are selecting based on attributes.&amp;nbsp; In this example&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"dissBuffs_lyr"&lt;/SPAN&gt;&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; &lt;SPAN class="string token"&gt;"sumPoint_2 &amp;gt; 1"&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are selecting all records that have the attribute "sumPoint_2" that is greater than 1.&amp;nbsp; The function then stores this in memory as whatever you want to call the variable; in this case "NEW_SELECTION."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post a link to your other post with details? Are you trying to join multiple tables? I need to know more context before I can provide you an appropriate answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Alex&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 13:48:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271254#M20980</guid>
      <dc:creator>AlexanderBrown5</dc:creator>
      <dc:date>2017-12-15T13:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: Select Layer By Attribute in Python</title>
      <link>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271255#M20981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/206718-various-issues-with-selectlayerbyattributemanagement-within-joined-features-in-python"&gt;https://community.esri.com/thread/206718-various-issues-with-selectlayerbyattributemanagement-within-joined-features-in-python&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Think I got it figured with the help of others...something weird about referencing table name and then ".fieldname". I was ref layername...currently testing when feature classes have same names now though because I still suspect issues..thanks for any assist&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 15:19:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/select-layer-by-attribute-in-python/m-p/271255#M20981</guid>
      <dc:creator>DerekNelson</dc:creator>
      <dc:date>2017-12-15T15:19:02Z</dc:date>
    </item>
  </channel>
</rss>

