<?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: Distinct query on multiple tables in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532410#M41688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Depends what you are trying to do, but you could try ArcSDESqlExecute: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000057000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000057000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Sep 2011 15:42:00 GMT</pubDate>
    <dc:creator>LoganPugh</dc:creator>
    <dc:date>2011-09-29T15:42:00Z</dc:date>
    <item>
      <title>Distinct query on multiple tables</title>
      <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532409#M41687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi there&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How would I go about doing a distinct query on multiple tables using Python? I am working in ArcMap 10.0.2 with a geodatabase accessed through ArcSDE 9.3.1 and held on an Oracle 10g database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 14:10:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532409#M41687</guid>
      <dc:creator>TimLangner</dc:creator>
      <dc:date>2011-09-29T14:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct query on multiple tables</title>
      <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532410#M41688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Depends what you are trying to do, but you could try ArcSDESqlExecute: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000057000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000057000000.htm&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Sep 2011 15:42:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532410#M41688</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-09-29T15:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct query on multiple tables</title>
      <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532411#M41689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example on how to do this using the 'ArcSDESqlExecute' function, as lpugh01 mentioned:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;PRE&gt;import arcpy&lt;/PRE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sdeConn = arcpy.ArcSDESQLExecute("GIS01", "sde:oracle11g:orcl", "", "vector", "vector")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tableList = ["School_District, "Building_Sites", "Parcels"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for table in tableList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print table + " contains the following cities:"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print sdeConn.execute('select distinct City from ' + table)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; except AttributeError:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "None, field does not exist"&lt;PRE&gt;&lt;/PRE&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code will run through each table and search for a field named 'City' and return the distinct values.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Sep 2011 10:46:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532411#M41689</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2011-09-30T10:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct query on multiple tables</title>
      <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532412#M41690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Tim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is an example on how to do this using the 'ArcSDESqlExecute' function, as lpugh01 mentioned:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

sdeConn = arcpy.ArcSDESQLExecute("GIS01", "sde:oracle11g:orcl", "", "vector", "vector")

tableList = ["School_District, "Building_Sites", "Parcels"]

for table in tableList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print table + " contains the following cities:"
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print sdeConn.execute('select distinct City from ' + table)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except AttributeError:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "None, field does not exist"&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above code will run through each table and search for a field named 'City' and return the distinct values.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:09:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532412#M41690</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T23:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct query on multiple tables</title>
      <link>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532413#M41691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your comments.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That is just what I was looking for. I assume could I then create a view of the results which is accessible in ArcMap, although it wouldn't be possible to update it but then it isn't possible to do that is a Make Query Table, which I have been using.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I actually did the distinct work in Excel this time and then used the Make Query Table to join this new table. I then exported this new table because it isn't possible to do a relate on a Make Query Table. For sound reasons I am sure but then I fail to see the sound reasons why a make query table can't be edited in the first place. Hopefully ESRI will add such a feature in a later release of ArcMap. By importing this new table I could do a relate to get the rows that did not match and I could then manually update them. Quite long winded but it at least allowed me to do what I required.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2011 07:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/distinct-query-on-multiple-tables/m-p/532413#M41691</guid>
      <dc:creator>TimLangner</dc:creator>
      <dc:date>2011-10-12T07:43:10Z</dc:date>
    </item>
  </channel>
</rss>

