<?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: Using Subqueries in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132913#M49892</link>
    <description>&lt;P&gt;Is the Geocoded_20210412 table in the same GDB as the data set being selected against?&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jan 2022 15:46:32 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2022-01-12T15:46:32Z</dc:date>
    <item>
      <title>Using Subqueries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132225#M49783</link>
      <description>&lt;P&gt;Hello, I've got a File Geodatabase and I'm trying to use a subquery to compare the data in one table with the data in another table.&lt;/P&gt;&lt;P&gt;Here's my query (using select by attributes) - I'm trying to select the rows in the table Geocoded_20201123 using a subquery that select rows from the table Geocoded_20210412&lt;/P&gt;&lt;P&gt;My_ID NOT IN (SELECT My_ID FROM Geocoded_20210412)&lt;/P&gt;&lt;P&gt;However, this SQL does not validate and when I'm typing, the Geocoded_20210412 table doesn't "pop up" as an option.&lt;/P&gt;&lt;P&gt;Documentation says it should work??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Mike...&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jan 2022 22:13:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132225#M49783</guid>
      <dc:creator>MikeBHamsa</dc:creator>
      <dc:date>2022-01-10T22:13:59Z</dc:date>
    </item>
    <item>
      <title>Re: Using Subqueries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132387#M49812</link>
      <description>&lt;P&gt;AFAIK, anything that requires a "where_clause" (e.g. SelectLayerByAttribute or SearchCursor) can only apply to the target table. You can not use other tables in the query.&lt;/P&gt;&lt;P&gt;So you have to do the sub query yourself: Open the Python window, copy this code and excute it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;exclude_field = "My_ID"
exclude_table = "Geocoded_20210412"
select_table = "Geocoded_20201123"

# SELECT exclude_field FROM exclude_table
exclude_values = [row[0] for row in arcpy.da.SearchCursor(exclude_table, [exclude_field])]

# WHERE exclude_field NOT IN (1, 2, 3)
# WHERE exclude_field NOT IN ('a', 'b', 'c')
try:
    if isinstance(exclude_values[0], str):
        where = "{} NOT IN ('{}')".format(exclude_field, "', '".join(exclude_values))
    else:
        where = "{} NOT IN ({})".format(exclude_field, ", ".join([str(x) for x in exclude_values]))
except IndexError:
    where = None

arcpy.management.SelectLayerByAttribute(select_table, 'NEW_SELECTION', where)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 11:10:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132387#M49812</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-01-11T11:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using Subqueries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132912#M49891</link>
      <description>&lt;P&gt;Johannes,&lt;/P&gt;&lt;P&gt;The WHERE clause &lt;STRONG&gt;does&lt;/STRONG&gt; allow you to query other feature classes or tables in the same GDB as the data set being selected against.&amp;nbsp; That said, not ever data source supports is (like shape files).&amp;nbsp; Also, not every data source supports all the functionality the same.&amp;nbsp; The Subqueries section of &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm" target="_blank"&gt;SQL reference for query expressions used in ArcGIS—ArcGIS Pro | Documentation&lt;/A&gt; covers most of the details.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 15:45:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132912#M49891</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2022-01-12T15:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Subqueries</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132913#M49892</link>
      <description>&lt;P&gt;Is the Geocoded_20210412 table in the same GDB as the data set being selected against?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 15:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/using-subqueries/m-p/1132913#M49892</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2022-01-12T15:46:32Z</dc:date>
    </item>
  </channel>
</rss>

