<?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 - Correct syntax for expression in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387147#M13237</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Question regarding arcpy.SelectLayerByAttribute_management:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can not figure out the problem with the following syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("Faults_2","NEW_SELECTION"," [names2]='Wabash Valley liquefaction features' ")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Result: Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer "Faults_2" is a geodatabase feature class. I have zero experience with Python, any help is much appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Terry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 31 Mar 2012 18:39:15 GMT</pubDate>
    <dc:creator>TerrenceDolan</dc:creator>
    <dc:date>2012-03-31T18:39:15Z</dc:date>
    <item>
      <title>SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387138#M13228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having some trouble running ArcGIS 10 Python scripting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to select the attributes in my layer based on a number of expressions. I don't think I have the Syntax correct. Although, I've followed what is posted here: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000071000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000071000000&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the portion of my code that is giving me the error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sel_pts_lyr is a feature layer, and the join I used to generate the data fields was done using env.qualifiedFieldNames = False.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running this in gp = arcgisscripting.create(9.3).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; #Select Analysis&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print "Attempting Select"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression1 = ' \"ELEV\" &amp;lt;= \"Elev_metre \" + 100 AND \"ELEV\" &amp;gt;= \"Elev_metre\" - 100 '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression2 = ' \"SLP\" &amp;lt;= \"mean_slp\"+ \"sd_slp\" AND \"SLP\" &amp;gt;= \"mean_slp\" - \"sd_slp\" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression3 = ' \"ASP\" &amp;lt;= \"mean_asp\" + \"sd_asp\" AND \"ASP\" &amp;gt;= \"mean_asp\" - \"sd_asp\" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "NEW_SELECTION", expression1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "SUBSET_SELECTION", expression2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "SUBSET_SELECTION", expression3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR OUTPUT&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\data2\smart_clip2\model_clip.py", line 91, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "NEW_SELECTION", expression1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4259, in SelectLayerByAttribute&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any assistance would be very appreciated!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Katrina&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 01:39:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387138#M13228</guid>
      <dc:creator>KatrinaBennett</dc:creator>
      <dc:date>2012-03-23T01:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387139#M13229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try it without escaping the double quotes:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;expression1 = ' "ELEV" &amp;lt;= "Elev_metre " + 100 AND "ELEV" &amp;gt;= "Elev_metre" - 100 '&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When mixing the different kinds of quote signs escaping should not be necessary.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 08:05:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387139#M13229</guid>
      <dc:creator>FabianBlau</dc:creator>
      <dc:date>2012-03-23T08:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387140#M13230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also trying to run a SelectLayerByAttribute_management command and I keep getting an error.&amp;nbsp; My line of code is as simple as can be, I don't understand the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("landuse", "NEW_SELECTION", " [LU_2008]= 'Cemetery' ")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help or suggestions are much appreciated,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 13:24:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387140#M13230</guid>
      <dc:creator>MikeWissner</dc:creator>
      <dc:date>2012-03-23T13:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387141#M13231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I figured out that for my code I don't need the brackets around the field name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But now when I run the code, it says its completed successfully, but no selection is visible in my data frame.&amp;nbsp; Very frustrating.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 13:39:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387141#M13231</guid>
      <dc:creator>MikeWissner</dc:creator>
      <dc:date>2012-03-23T13:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387142#M13232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The field name needs to be enclosed by double quotes:&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.SelectLayerByAttribute_management("landuse", "NEW_SELECTION", "\"LU_2008\" = 'Cemetery' ")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 13:55:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387142#M13232</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-03-23T13:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387143#M13233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Bruce.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem solved, I wasn't escaping the double quotes around the field name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;good luck Katrina&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 14:09:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387143#M13233</guid>
      <dc:creator>MikeWissner</dc:creator>
      <dc:date>2012-03-23T14:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387144#M13234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried what was suggested, to remove the backslashes. I am still getting the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; #Select Analysis&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print "Attempting Select"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression1 = ' "ELEV" &amp;lt;= "Elev_metre" + 100 AND "ELEV" &amp;gt;= "Elev_metre" - 100 '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression2 = ' "SLP" &amp;lt;= "mean_slp"+ "sd_slp" AND "SLP" &amp;gt;= "mean_slp" - "sd_slp" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression3 = ' "ASP" &amp;lt;= "mean_asp" + "sd_asp" AND "ASP" &amp;gt;= "mean_asp" - "sd_asp" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "NEW_SELECTION", expression1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "SUBSET_SELECTION", expression2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "SUBSET_SELECTION", expression3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\data2\smart_clip2\model_clip.py", line 91, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "NEW_SELECTION", expression1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 4259, in SelectLayerByAttribute&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 16:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387144#M13234</guid>
      <dc:creator>KatrinaBennett</dc:creator>
      <dc:date>2012-03-23T16:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387145#M13235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wonder if this might make a difference:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;expression1 = 'ABS("ELEV" - "Elev_metre") &amp;lt;= 100 '
expression2 = 'ABS("SLP" - "mean_slp") &amp;lt;= "sd_slp" '
expression3 = 'ABS("ASP" - "mean_asp") &amp;lt;= "sd_asp" '
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:47:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387145#M13235</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2021-12-11T17:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387146#M13236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok, it worked with some minor modification! In the end I had to make a new column for ELEV because the original column had different precision and scale, which apparently matters in the Python version of the Select Layer By Attribution, but not the Tool version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I combined these together using the ADD because the SUBSET_SELECTION did not appear to be working. I kept getting a zero selection in my shapefile, which was incorrect.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for you help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Final code lines used are as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; expression1 = 'ABS("Elev2" - "Elev_metre") &amp;lt;= 100 AND ABS("SLP" - "mean_slp") &amp;lt;= "sd_slp" AND ABS("ASP" - "mean_asp") &amp;lt;= "sd_asp" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; #expression2 = 'ABS("SLP" - "mean_slp") &amp;lt;= 2*"sd_slp" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; #expression3 = 'ABS("ASP" - "mean_asp") &amp;lt;= 2*"sd_asp" '&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.SelectLayerByAttribute_management(sel_pts_lyr, "NEW_SELECTION", expression1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Katrina&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Mar 2012 21:51:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387146#M13236</guid>
      <dc:creator>KatrinaBennett</dc:creator>
      <dc:date>2012-03-23T21:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387147#M13237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Question regarding arcpy.SelectLayerByAttribute_management:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can not figure out the problem with the following syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SelectLayerByAttribute_management("Faults_2","NEW_SELECTION"," [names2]='Wabash Valley liquefaction features' ")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Result: Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer "Faults_2" is a geodatabase feature class. I have zero experience with Python, any help is much appreciated!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Terry&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 31 Mar 2012 18:39:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387147#M13237</guid>
      <dc:creator>TerrenceDolan</dc:creator>
      <dc:date>2012-03-31T18:39:15Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387148#M13238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hy Katrina,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; Just a notice:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;did you include the next line:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy&amp;nbsp; # or argisscripting
# ...
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:47:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387148#M13238</guid>
      <dc:creator>AdelItani</dc:creator>
      <dc:date>2021-12-11T17:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387149#M13239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Terry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This should work for you:&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.SelectLayerByAttribute_management("Faults_2", "NEW_SELECTION", "\"names2\" = 'Wabash Valley liquefaction features'")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Field names in a GeoDB need to be surrounded in double quote, not brackets.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Apr 2012 12:40:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387149#M13239</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-04-02T12:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387150#M13240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am having problems with a similar piece of Python code to Terry's but my field is long integer and value is a variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using Terry's code could anyone show me the correct syntax if the field value is a variable of long integer type? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have found a few examples via ESRI and other sites but non seem to work for me. Data is in a file GDB. ArcGIS version 10.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tony Enberg&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 05:33:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387150#M13240</guid>
      <dc:creator>TonyEnberg</dc:creator>
      <dc:date>2012-08-08T05:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: SelectLayerByAttribute_management - Correct syntax for expression</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387151#M13241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If the field type is integer, you don't enclose the expected value in single quotes. That allows you to simplify the expression even more by using the single quotes to encompass the entire expression. Use Python's string substitution to insert the value of the variable:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.SelectLayerByAttribute_management("FCname", "NEW_SELECTION", '"integerField" = %i' % variableName)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Aug 2012 12:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/selectlayerbyattribute-management-correct-syntax/m-p/387151#M13241</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2012-08-08T12:12:12Z</dc:date>
    </item>
  </channel>
</rss>

