<?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 ArcPy Select by Attribute: Selection Query error in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265338#M66357</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep receiving a 000358 error on my select by attribute function. I know it is the SQL in the selection query but I am so lost on what I should do to fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, the purpose of the script is to utilize the the names of school districts in the "SCHOOL_DIS" attribute column in a shape file, and preform a buffer around each individual district to produce its own shape file, so one school district buffer per shape file.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor (input_shape, ["SCHOOL_DIS"]) as cursor:
     for row in cursor:
       district_name = row[0]
       selection_query = "SCHOOL_DIS = " + district_name
       arcpy.management.SelectLayerByAttribute (input_shape, "NEW_SELECTION", selection_query, "")    
       outputfile = os.path.join(path, "{}_buf_5mile.shp".format(district_name))
       arcpy.analysis.Buffer (input_shape, outputfile, "5 Miles", "","","","","")                                                     
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 04:47:33 GMT</pubDate>
    <dc:creator>G_Fortress</dc:creator>
    <dc:date>2023-03-08T04:47:33Z</dc:date>
    <item>
      <title>ArcPy Select by Attribute: Selection Query error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265338#M66357</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I keep receiving a 000358 error on my select by attribute function. I know it is the SQL in the selection query but I am so lost on what I should do to fix it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially, the purpose of the script is to utilize the the names of school districts in the "SCHOOL_DIS" attribute column in a shape file, and preform a buffer around each individual district to produce its own shape file, so one school district buffer per shape file.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor (input_shape, ["SCHOOL_DIS"]) as cursor:
     for row in cursor:
       district_name = row[0]
       selection_query = "SCHOOL_DIS = " + district_name
       arcpy.management.SelectLayerByAttribute (input_shape, "NEW_SELECTION", selection_query, "")    
       outputfile = os.path.join(path, "{}_buf_5mile.shp".format(district_name))
       arcpy.analysis.Buffer (input_shape, outputfile, "5 Miles", "","","","","")                                                     
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 04:47:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265338#M66357</guid>
      <dc:creator>G_Fortress</dc:creator>
      <dc:date>2023-03-08T04:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Select by Attribute: Selection Query error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265339#M66358</link>
      <description>&lt;P&gt;Please add your code as formatted text, not as a screenshot.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;Community Help Documents &amp;gt; How to insert code in your post&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Here is an example of code as formatted text
import arcpy

for i in range(10):
    print("code as formatted text")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 04:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265339#M66358</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2023-03-08T04:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Select by Attribute: Selection Query error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265340#M66359</link>
      <description>&lt;P&gt;added&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 04:48:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265340#M66359</guid>
      <dc:creator>G_Fortress</dc:creator>
      <dc:date>2023-03-08T04:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Select by Attribute: Selection Query error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265360#M66365</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/specifying-a-query.htm" target="_blank"&gt;Specifying a query in Python—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;text would have to be enclosed by a single quote I think&lt;/P&gt;&lt;LI-CODE lang="python"&gt;district_name = "a"
"SCHOOL_DIS = '{}'".format(district_name)
"SCHOOL_DIS = 'a'"&lt;/LI-CODE&gt;&lt;P&gt;but you had better check fhe fieldname delimiter syntax for your input source&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/specifying-a-query.htm" target="_blank"&gt;Specifying a query in Python—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 09:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpy-select-by-attribute-selection-query-error/m-p/1265360#M66365</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T09:25:01Z</dc:date>
    </item>
  </channel>
</rss>

