<?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: Python Tool - User input then Select by Attribute in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261203#M20088</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know. The following example works for me. Try hardcoding your parameters to something you're confident should work. Also, try manually running the SelectLayerByAttribute tool through the GUI, and looking at the syntax in the Results window to see the Python syntax it generates (right-click -&amp;gt; Copy as Python Snippet).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;InputFeatureClass = 'points'
InputField = 'bearing'
InputValue = '30'
whereclause = """{} = {}""".format(arcpy.AddFieldDelimiters(InputFeatureClass,InputField),InputValue)
arcpy.SelectLayerByAttribute_management(InputFeatureClass,"NEW_SELECTION",whereclause)‍‍‍‍‍&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:49:30 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2021-12-11T12:49:30Z</dc:date>
    <item>
      <title>Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261183#M20068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Any ideas why I am having problems by trying to have user input a string value for a feature, then have the feature selected.&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;#Import Modules&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;arcpy
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Layers"&lt;/SPAN&gt;&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="comment token"&gt;#os.chdir(r'C:\Users\dunderwood\Documents\MY_TEMPLATES\WASTEWATER_EDIT_TEMPLATE')&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Set the parameters&lt;/SPAN&gt;
InputFeatureClass &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; FACILITYID &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; InputValue"
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;InputFeatureClass&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; whereClause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;zoomToSelectedFeatures&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;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&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;/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;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/316216_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:49:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261183#M20068</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-11T12:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261184#M20069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem is your where clause. See here for how to specify a query in Python, especially the last example:&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/arcpy/get-started/specifying-a-query.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/get-started/specifying-a-query.htm"&gt;Specifying a query in Python—ArcPy Get Started | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;whereclause = """{} = 2""".format(arcpy.AddFieldDelimiters(fc, fieldname))&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>Mon, 06 Feb 2017 21:26:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261184#M20069</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-06T21:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261185#M20070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/select.htm"&gt;Select analysis&lt;/A&gt;&amp;nbsp;has a code snippet and links to formulating sql queries that will work.&amp;nbsp; Your query lacks the proper quotation sequence&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 21:26:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261185#M20070</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-06T21:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261186#M20071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the quick responses.&lt;/P&gt;&lt;P&gt;I will work on this, at first glance, I need brackets and/or add field delimiter, etc.&amp;nbsp;I am taking away from this that my sql clause needs work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 21:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261186#M20071</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-06T21:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261187#M20072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe you can just use this for your case:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{} = {}"""&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;InputFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'FACILITYID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputValue&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 22:02:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261187#M20072</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-06T22:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261188#M20073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does it need &lt;SPAN&gt;'FACILITYID' since it is referenced in InputValue ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I tried this line and still having difficulty. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 23:22:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261188#M20073</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-06T23:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261189#M20074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, right. It should be like below so that all three input variables are dynamic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;whereClause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{} = {}"""&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;InputFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; InputField&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputValue&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 23:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261189#M20074</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-06T23:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261190#M20075</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get the following message, don't know what is wrong.&lt;/P&gt;&lt;P&gt;Executing: QueryMxdFeatureClass "SWR Layers\Manholes" FACILITYID 5564&lt;/P&gt;&lt;P&gt;Start Time: Mon Feb 06 15:41:32 2017&lt;/P&gt;&lt;P&gt;Running script QueryMxdFeatureClass...&lt;/P&gt;&lt;P&gt;Failed script QueryMxdFeatureClass...&lt;/P&gt;&lt;P&gt;SyntaxError: invalid syntax (QueryMxdFeatureClass.py, line 19)&lt;/P&gt;&lt;P&gt;Failed to execute (QueryMxdFeatureClass).&lt;/P&gt;&lt;P&gt;Failed at Mon Feb 06 15:41:33 2017 (Elapsed Time: 0.67 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my updated syntax&lt;/P&gt;&lt;P&gt;&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="comment token"&gt;#Import Modules&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;arcpy
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Layers"&lt;/SPAN&gt;&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="comment token"&gt;# Set the parameters&lt;/SPAN&gt;
InputFeatureClass &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

whereclause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{} = {}"""&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;InputFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputField&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputValue&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;InputFeatureClass&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; whereclause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;zoomToSelectedFeatures&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;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&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;/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;SPAN&gt;‍&lt;/SPAN&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 12:49:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261190#M20075</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-11T12:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261191#M20076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you put in some print statements so that the exact format can be examined.&amp;nbsp; If the input value is a number there is one format, if the input value there is another... plus Darren updated his where clause with a syntax different thatn you provided on line 10&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 23:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261191#M20076</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-06T23:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261192#M20077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your where clause is ever-so-slightly different from mine - missing a ')' after InputField.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Feb 2017 23:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261192#M20077</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-06T23:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261193#M20078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh didn't catch that. I changed it.&amp;nbsp; I am unable to use print statements to test it out since I am running it as a tool which doesn't return print statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;whereclause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{} = {}"""&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;InputFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputField&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputValue&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 00:03:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261193#M20078</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-07T00:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261194#M20079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;arcpy.AddMessage("Same as print when running tools")&amp;nbsp; # for print equivalent in arctoolbox&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 00:56:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261194#M20079</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-02-07T00:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261195#M20080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. What messages would I want to troubleshoot my syntax ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 15:27:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261195#M20080</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-07T15:27:38Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261196#M20081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following yet it is not working. Something still wrong with the expression.&lt;/P&gt;&lt;P&gt;Does it matter whether it is a .sde feature class .or file geodatabase feature ?&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="comment token"&gt;#Import Modules&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;arcpy
&lt;SPAN class="comment token"&gt;#Set to current mxd and dataframe&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'CURRENT'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Layers"&lt;/SPAN&gt;&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="comment token"&gt;# Set the tool parameters&lt;/SPAN&gt;
InputFeatureClass &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputField &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&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;
InputValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# SQL expression used in selecting a feature&lt;/SPAN&gt;
whereclause &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"""{} = {}"""&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;InputFeatureClass&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputField&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;InputValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Select feature by facilityid (InputValue)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByAttribute_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;InputFeatureClass&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; whereclause&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;zoomToSelectedFeatures&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;RefreshActiveView&lt;SPAN class="punctuation token"&gt;(&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;/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;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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:49:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261196#M20081</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2021-12-11T12:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261197#M20082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try passing the full path to your feature class for InputFeatureClass. Otherwise, what's the exact error message?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 16:50:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261197#M20082</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-07T16:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261198#M20083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I placed the full path and still no luck. Here is the following error message.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;File "C:\Users\...Scripts\QueryMxdFeatureClass.py", line 18, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management(InputFeatureClass, "NEW_SELECTION", whereclause)&lt;/P&gt;&lt;P&gt;File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6688, in SelectLayerByAttribute&lt;/P&gt;&lt;P&gt;raise e&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000358: Invalid expression&lt;/P&gt;&lt;P&gt;Failed to execute (SelectLayerByAttribute).&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;Failed to execute (QueryMxdFeatureClass).&lt;/P&gt;&lt;P&gt;Failed at Tue Feb 07 09:06:24 2017 (Elapsed Time: 0.47 seconds)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 17:10:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261198#M20083</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-07T17:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261199#M20084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;What do you get when you print the whereclause?&lt;/SPAN&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;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;whereclause&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 17:17:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261199#M20084</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-07T17:17:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261200#M20085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Interesting,&amp;nbsp;I&amp;nbsp;used&amp;nbsp;arcpy&lt;SPAN&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN&gt;(&lt;/SPAN&gt;whereclause&lt;SPAN&gt;) and get &amp;nbsp;the following results.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am assuming&amp;nbsp;that it successfully received the Inputvalue., but can't select the feature.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Executing: QueryMxdFeatureClass "SWR Layers\Manholes" FACILITYID 5564&lt;/P&gt;&lt;P&gt;Start Time: Tue Feb 07 09:19:10 2017&lt;/P&gt;&lt;P&gt;Running script QueryMxdFeatureClass...&lt;/P&gt;&lt;P&gt;"FACILITYID" = 5564&lt;/P&gt;&lt;P&gt;Failed script QueryMxdFeatureClass...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 17:24:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261200#M20085</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-07T17:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261201#M20086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try moving the "Manholes" layer outside of the "SWR Layers" group and try it just as "Manholes"?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 17:33:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261201#M20086</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2017-02-07T17:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Python Tool - User input then Select by Attribute</title>
      <link>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261202#M20087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I removed it from the group and same error. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Feb 2017 17:40:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-tool-user-input-then-select-by-attribute/m-p/261202#M20087</guid>
      <dc:creator>DevinUnderwood2</dc:creator>
      <dc:date>2017-02-07T17:40:17Z</dc:date>
    </item>
  </channel>
</rss>

