<?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: How to access Field Names in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267867#M20634</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you elaborate on "isn't working for me?"&amp;nbsp; Are you getting errors or unexpected results?&amp;nbsp; If errors, what errors exactly (paste the error message here)?&amp;nbsp; If unexpected results, what are you getting and what do you expect?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Aug 2017 16:31:46 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2017-08-04T16:31:46Z</dc:date>
    <item>
      <title>How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267866#M20633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I am working on a custom tool that uses one of the existing fields to make a selection by attribute. For example, say I have a feature called &lt;STRONG&gt;Target Feature&amp;nbsp;&lt;/STRONG&gt;and in the feature, the fields were called Field1, Field2, Field3, and Field4. I am trying to get a variable to be set equal to arcpy.ListFields('Target Feature') and then to check if a field name is in that feature. The selection I want wasn't working, no selection was being made actually. Here's what I was leaning towards but it didn't work for me:&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

fieldList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Target Feature'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fieldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field3'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
fieldValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fieldName &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fieldList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fieldValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fieldName&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 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;'Target Feature'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; NEW_SELECION&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Field3 LIKE "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fieldValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &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;‍‍‍‍‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But this isn't working for me. Any help is appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267866#M20633</guid>
      <dc:creator>VishalShah2</dc:creator>
      <dc:date>2021-12-11T13:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267867#M20634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you elaborate on "isn't working for me?"&amp;nbsp; Are you getting errors or unexpected results?&amp;nbsp; If errors, what errors exactly (paste the error message here)?&amp;nbsp; If unexpected results, what are you getting and what do you expect?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:31:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267867#M20634</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-08-04T16:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267868#M20635</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Always be careful to understand what an ArcPy function returns. &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/listfields.htm"&gt;ListFields&lt;/A&gt; returns a list of &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/field.htm"&gt;Field&lt;/A&gt; objects, which while they include name, also includes type, isNullable, length and a number of other properties. You'd need to use a list comprehension to map the array of Fields to an array of names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- V&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:49:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267868#M20635</guid>
      <dc:creator>VinceAngelo</dc:creator>
      <dc:date>2017-08-04T16:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267869#M20636</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Vishal,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are some issues with your if statements, so currently the script will never make it to the SelectLayerByAttribute call.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first conditional is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fieldList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Target Feature'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fieldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Field3'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
fieldValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fieldName &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fieldList&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fieldName is a list, since you surrounded it with square brackets. So you are checking if a&amp;nbsp;&lt;STRONG&gt;list&lt;/STRONG&gt; holding 'Field3' is in fieldList, not the 'Field3' &lt;STRONG&gt;string&lt;/STRONG&gt; itself. The result of arcpy.ListFields contains Field objects which possess a name Property - so we can use a list comprehension to extract them. The result will look something like: ['Field1', 'Field2', 'Field3'], so we can see ['Field3'] isn't inside, however 'Field3' by itself is.&amp;nbsp;&lt;A href="https://stackoverflow.com/questions/3389574/check-if-multiple-strings-exist-in-another-string" rel="nofollow noopener noreferrer" target="_blank"&gt;This post&lt;/A&gt;&amp;nbsp;explains how to search for a list of values within another list, and may help clear it up further.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The second conditional:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fieldValue &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fieldName&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;Has a similar issue - The list ['%45B%'] does not exist inside ['Field3'], which again has no sublists. At this point, instead you may want to check the value of each row inside 'Target Feature', this is where&amp;nbsp;&lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/get-started/data-access-using-cursors.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Cursors&lt;/A&gt;&amp;nbsp;come in. However, for what you are trying to do in this script, Cursors are unnecessary, I just wanted to mention them for your benefit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You don't need to use cursors, because the arcpy.SelectLayerByAttribute_management() tool allows you to provide a query, which you are doing in your above example. This loops through the feature class automatically, cursors loop through it manually.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So therefore, we just need a single conditional statement in this case. With these changes, this should be the result:&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

fieldList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Target Feature'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
fieldName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Field3'&lt;/SPAN&gt;
fieldValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# list comp to extract field names&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; fieldName &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; fieldList&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Field3 LIKE "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fieldValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"'"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; 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;'Target Feature'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; NEW_SELECION&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; query&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Its also worth mentioning, in case you run into it, that in some cases 'Target Feature' won't be enough and you may need the full path to the dataset on disk.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Shoutout to &lt;A href="https://community.esri.com/people/vangelo-esristaff" target="_blank"&gt;vangelo-esristaff&lt;/A&gt;‌ for a reminder on the Field objects &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267869#M20636</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2021-12-11T13:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267870#M20637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So if the field name is edited in line 4, how about this for line 9:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; fieldName &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" LIKE '"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fieldValue&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string 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>Fri, 04 Aug 2017 17:10:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267870#M20637</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-08-04T17:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267871#M20638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes good point, that will work and makes it more robust.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:28:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267871#M20638</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2017-08-04T17:28:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267872#M20639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry about that Joshua, my issue was that the selection wasn't being made. Was bogged down by other projects I forgot to mention what wasn't working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 17:29:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267872#M20639</guid>
      <dc:creator>VishalShah2</dc:creator>
      <dc:date>2017-08-04T17:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267873#M20640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Clinton,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What if fieldValue had more than one input? Say:&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;fieldValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%46A%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%47C%'&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;Would that still work the way you have the script written?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 18:58:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267873#M20640</guid>
      <dc:creator>VishalShah2</dc:creator>
      <dc:date>2017-08-04T18:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267874#M20641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case it would be appropriate to surround the three values in square brackets to create a list, because you have multiple strings and want to compare for each one of them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fieldValues &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%46A%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%47C%'&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;Then you can use the SQL&amp;nbsp;&lt;STRONG&gt;IN&lt;/STRONG&gt; operator instead of&amp;nbsp;&lt;STRONG&gt;LIKE&lt;/STRONG&gt; in that case. The syntax would be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;query &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Field3 IN"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"("&lt;/SPAN&gt; &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;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fieldValues&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;")"&lt;/SPAN&gt;‍
&lt;SPAN class="comment token"&gt;# "Field3 IN (‍‍'%45B%', '%46A%', '%47C%')‍‍‍‍&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267874#M20641</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2021-12-11T13:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267875#M20642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But I'd want to check to see if the list that is set to fieldValues is in Field3. So wouldn't it be the other way around from how you have the join listed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 20:04:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267875#M20642</guid>
      <dc:creator>VishalShah2</dc:creator>
      <dc:date>2017-08-04T20:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267876#M20643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the query the 'Field3' value gets replaced with the value within that column, for each row. So its checking if the value of the Field3 column matches any of those 3 strings and if so the row gets selected.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The join is just a python function on the String type (as you can see I'm defining a string inline:&amp;nbsp;&lt;STRONG&gt;', '&amp;nbsp;&lt;/STRONG&gt;then calling the function .join() on it), concatenating the 3 strings from the list together, separated&amp;nbsp;by&amp;nbsp;a comma and space into a single string. This has to be done because the query is a single string.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you used&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;fieldValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%45B%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%46A%'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'%47C%'&lt;/SPAN&gt;‍
&lt;SPAN class="comment token"&gt;# ('%45B%', '%46A%', '%47C%'‍)&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;It will work as well, but will give you a Tuple instead of a list. This works fine in the current situation, but if you had a script with variable fieldValues, a Tuple wouldn't work because the values within are not&amp;nbsp;mutable - this is why I suggested the list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that clear it up?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:07:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267876#M20643</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2021-12-11T13:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267877#M20644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It does! Thank you so much Clinton!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 20:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267877#M20644</guid>
      <dc:creator>VishalShah2</dc:creator>
      <dc:date>2017-08-04T20:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to access Field Names</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267878#M20645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My pleasure &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 20:23:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-field-names/m-p/267878#M20645</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2017-08-04T20:23:01Z</dc:date>
    </item>
  </channel>
</rss>

