<?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 Error 000358: Invalid Expression when trying to select layer by attribute in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844165#M518</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm creating a script where I'm trying to select all the null values based on a specific field. The feature is joined with another feature, thus altering the title of fields to be FeatureName_FieldName. I want to keep these titles as I will be exporting the table and if I set qualified field names to False, the fields won't be able to be properly interpreted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mayDevice = mayFeature+"_"+"DEVICE_ID"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; whereClause = mayDevice "IS NULL"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(mayFeature, "NEW_SELECTION", whereClause)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to include a variable in an "is null" expression.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Aug 2018 17:04:51 GMT</pubDate>
    <dc:creator>TiffanieLaw</dc:creator>
    <dc:date>2018-08-21T17:04:51Z</dc:date>
    <item>
      <title>Error 000358: Invalid Expression when trying to select layer by attribute</title>
      <link>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844165#M518</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm creating a script where I'm trying to select all the null values based on a specific field. The feature is joined with another feature, thus altering the title of fields to be FeatureName_FieldName. I want to keep these titles as I will be exporting the table and if I set qualified field names to False, the fields won't be able to be properly interpreted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mayDevice = mayFeature+"_"+"DEVICE_ID"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; whereClause = mayDevice "IS NULL"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; arcpy.SelectLayerByAttribute_management(mayFeature, "NEW_SELECTION", whereClause)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to include a variable in an "is null" expression.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:04:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844165#M518</guid>
      <dc:creator>TiffanieLaw</dc:creator>
      <dc:date>2018-08-21T17:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000358: Invalid Expression when trying to select layer by attribute</title>
      <link>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844166#M519</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some suggestions Tiffanie:&lt;/P&gt;&lt;P&gt;print the query out to check what it looks like&lt;/P&gt;&lt;P&gt;do one manually and copy the result&lt;/P&gt;&lt;P&gt;check&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm" title="http://pro.arcgis.com/en/pro-app/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm"&gt;SQL reference for query expressions used in ArcGIS—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt; there is an example there&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Aug 2018 17:15:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844166#M519</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-21T17:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000358: Invalid Expression when trying to select layer by attribute</title>
      <link>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844167#M520</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your whereClause as shown is missing a + sign and space before " IS NULL".&amp;nbsp; When joining strings, I like to use .format&amp;nbsp;as I find&amp;nbsp;the code is a bit clearer. &amp;nbsp;You might try something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;mayDevice = "{}_DEVICE_ID".format(mayFeature)

whereClause = "{} IS NULL".format(mayDevice)&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:20:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/error-000358-invalid-expression-when-trying-to/m-p/844167#M520</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-12T10:20:50Z</dc:date>
    </item>
  </channel>
</rss>

