<?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: ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute). in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023903#M59815</link>
    <description>&lt;P&gt;I don't notice&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm" target="_self"&gt;make feature layer&lt;/A&gt; anywhere.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Feb 2021 15:27:45 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-02-05T15:27:45Z</dc:date>
    <item>
      <title>ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).</title>
      <link>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023897#M59813</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;I have a query reading the Shape field, to return the number of records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code is:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    for ds in datasets:
        for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
            cursor = arcpy.SearchCursor(fc)
            new_name = fc.split('.')[-1]
            #print(new_name)

            #path = os.path.join(arcpy.env.workspace, ds, fc)
            #### PRINT full name
            rowitem = ([fc])
            #### PRINT Feature name
            #rowitem = ([new_name])
            print(rowitem)
            #Count_feat = arcpy.GetCount_management(rowitem.objectid) 
            query = "SELECT '*' FROM 'Shape'"
            #print(rowitem, query)
            arcpy.SelectLayerByAttribute_management(fc, "NEW_SELECTION", query ) 
            Count_feat = arcpy.GetCount_management(fc)
            print(Count_feat)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error message is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;START
LOOP
['server.gis.Rail_Systems']

Then error:

ExecuteError                              Traceback (most recent call last)
&amp;lt;ipython-input-24-43e73deac686&amp;gt; in &amp;lt;module&amp;gt;
     47             query = "SELECT '*' FROM 'Shape'"
     48             #print(rowitem, query)
---&amp;gt; 49             arcpy.SelectLayerByAttribute_management(fc, "NEW_SELECTION", query )
     50             Count_feat = arcpy.GetCount_management(fc)
     51             print(Count_feat)

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in SelectLayerByAttribute(in_layer_or_view, selection_type, where_clause, invert_where_clause)
   8752         return retval
   8753     except Exception as e:
-&amp;gt; 8754         raise e
   8755 
   8756 @gptooldoc('SelectLayerByLocation_management', None)

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in SelectLayerByAttribute(in_layer_or_view, selection_type, where_clause, invert_where_clause)
   8749     from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
   8750     try:
-&amp;gt; 8751         retval = convertArcObjectToPythonObject(gp.SelectLayerByAttribute_management(*gp_fixargs((in_layer_or_view, selection_type, where_clause, invert_where_clause), True)))
   8752         return retval
   8753     except Exception as e:

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py in &amp;lt;lambda&amp;gt;(*args)
    509         val = getattr(self._gp, attr)
    510         if callable(val):
--&amp;gt; 511             return lambda *args: val(*gp_fixargs(args, True))
    512         else:
    513             return convertArcObjectToPythonObject(val)

ExecuteError: ERROR 000358: Invalid expression
Failed to execute (SelectLayerByAttribute).&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate any pointers.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Clive&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 15:18:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023897#M59813</guid>
      <dc:creator>CliveSwan</dc:creator>
      <dc:date>2021-02-05T15:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).</title>
      <link>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023901#M59814</link>
      <description>&lt;P&gt;The&amp;nbsp;where_clause parameter is only that, the where clause portion of a full select statement. The fields and the table are implied with the other parameters. It looks like your intention is to select everything? Try this trick instead:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;query = "1=1"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;If you do intend to select something specific (instead of all records), just use the where clause, like:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;query = "someNameField = 'example' or someNumberField &amp;gt; 0"&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 15:26:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023901#M59814</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-02-05T15:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).</title>
      <link>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023903#M59815</link>
      <description>&lt;P&gt;I don't notice&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/make-feature-layer.htm" target="_self"&gt;make feature layer&lt;/A&gt; anywhere.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Feb 2021 15:27:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executeerror-error-000358-invalid-expression/m-p/1023903#M59815</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-02-05T15:27:45Z</dc:date>
    </item>
  </channel>
</rss>

