<?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: &amp;quot;Advanced&amp;quot; query selection of entities through a relationship in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863264#M5578</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It&amp;nbsp;can be solved by &lt;STRONG&gt;creating a&amp;nbsp;Hosted Feature Layer View&lt;/STRONG&gt; using the &lt;A href="https://doc.arcgis.com/en/arcgis-online/analyze/join-features.htm"&gt;Join feature tool in Online&lt;/A&gt;.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;STRONG&gt;BTW:&lt;/STRONG&gt;&amp;nbsp;this analysis tool&amp;nbsp;takes no credits for analysis and storage when creating a Hosted View.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This way you create a hosted feature layer view that joins the two tables together and &lt;STRONG&gt;returns a new hosted layer&lt;/STRONG&gt;&amp;nbsp;(a new item). Things to bear in mind:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;As data changes in your source tables the data accessed via the view will always be up to date&lt;/LI&gt;&lt;LI&gt;As you will have the fields from both tables available you will be also able to filter by any combination of fields&lt;/LI&gt;&lt;/UL&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;&amp;nbsp;in order to create a hosted layer view you do need to own both tables.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks to &lt;A href="https://community.esri.com/migrated-users/3511"&gt;Jeremy Bartley&lt;/A&gt;‌ for your help!,&lt;/P&gt;&lt;P&gt;Raúl&lt;/P&gt;&lt;DIV style="position: absolute; left: 238px; top: 222px;"&gt;&lt;DIV class="gtx-trans-icon"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Sep 2019 11:54:29 GMT</pubDate>
    <dc:creator>Raul_Jimenez</dc:creator>
    <dc:date>2019-09-26T11:54:29Z</dc:date>
    <item>
      <title>"Advanced" query selection of entities through a relationship</title>
      <link>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863262#M5576</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Requirement&lt;/STRONG&gt;&lt;/SPAN&gt;:&amp;nbsp;I&amp;nbsp;want/need to do this&amp;nbsp;using hosted feature services in&amp;nbsp;ArcGIS Online&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm just trying to do something&amp;nbsp;like this &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;with just one REST API call&lt;/STRONG&gt;&lt;/SPAN&gt;:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;SELECT&lt;/SPAN&gt; table1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;*&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;FROM&lt;/SPAN&gt;   table1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; table2
&lt;SPAN class="keyword token"&gt;WHERE&lt;/SPAN&gt;  table1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;primary_key &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; table2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;foreign_key
       &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; table1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Value1'&lt;/SPAN&gt; 
       &lt;SPAN class="operator token"&gt;AND&lt;/SPAN&gt; table2&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Value2'&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;Now I'm going to explain the approach I have been following and the issue I'm facing, but&amp;nbsp;maybe&amp;nbsp;the approach is wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;I created a file geodatabase in ArcGIS Pro with two Feature Classes&amp;nbsp;(table1 &amp;amp; table2)&lt;/LI&gt;&lt;LI&gt;I created a relationship class where:&amp;nbsp;table1.primary_key = table2.foreign_key&lt;/LI&gt;&lt;LI&gt;I published it in ArcGIS Online&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I tried to&amp;nbsp;do a similar query to this one&amp;nbsp;using the&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;query related records end point from the REST API&lt;/A&gt;&amp;nbsp;but&amp;nbsp;I couldn't:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;First, I noticed that&amp;nbsp;it is not possible to set the&amp;nbsp;&lt;STRONG&gt;objectIds&lt;/STRONG&gt; param to "*" (which I don't quite understand why) &amp;lt;- but I could manage it by setting&amp;nbsp;all the &lt;STRONG&gt;objectIds&lt;/STRONG&gt; manually.&lt;/LI&gt;&lt;LI&gt;But&amp;nbsp;the real problem I found was that in the&amp;nbsp;&lt;STRONG&gt;definitionExpression&lt;/STRONG&gt;&amp;nbsp;param &lt;SPAN style="text-decoration: underline;"&gt;I could only use attributes from one table/layer&lt;/SPAN&gt; (the&amp;nbsp;related one) but not from both of them.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So,&amp;nbsp;I'm not sure if the only way to solve this is programmatically by:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;First query one table to get &lt;SPAN style="text-decoration: underline;"&gt;only&lt;/SPAN&gt; the &lt;STRONG&gt;OBJECTIDs&lt;/STRONG&gt;&amp;nbsp;that meet all the criteria established to this table&lt;/LI&gt;&lt;LI&gt;And then&amp;nbsp;use the&amp;nbsp;&lt;A href="https://developers.arcgis.com/rest/services-reference/query-related-records-feature-service-.htm" style="color: #2989c5; text-decoration: none;" rel="nofollow noopener noreferrer" target="_blank"&gt;query related records&lt;/A&gt;&amp;nbsp;setting the&amp;nbsp;&lt;STRONG&gt;objectIds &lt;/STRONG&gt;to those I recovered in step 1 and set the&amp;nbsp;&lt;STRONG&gt;definitionExpression &lt;/STRONG&gt;to add the pending criteria (the one to filter also the data&amp;nbsp;within the related table).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this the way to solve what I'm trying to achieve or&amp;nbsp;there's some way to do it with just one API request?.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Raul&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;BTW: I also tried doing a JOIN in memory and then&amp;nbsp;selecting features by attributes and it worked in ArcGIS Pro, but I couldn't publish that on ArcGIS Online&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:42:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863262#M5576</guid>
      <dc:creator>Raul_Jimenez</dc:creator>
      <dc:date>2021-12-12T10:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: "Advanced" query selection of entities through a relationship</title>
      <link>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863263#M5577</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sorry for the inconvenience... but would you&amp;nbsp;know&amp;nbsp;if what I'm trying to do is possible? ^_^ // cc:&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/6443"&gt;Rene Rubalcava&lt;/A&gt;,&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/150026"&gt;Ionut Alixandroae&lt;/A&gt;, &lt;A href="https://community.esri.com/migrated-users/38895"&gt;Patrick Arlt&lt;/A&gt;‌, &lt;A href="https://community.esri.com/migrated-users/5600"&gt;Dave Bouwman&lt;/A&gt;‌, &lt;A href="https://community.esri.com/migrated-users/20431"&gt;Tom Wayson&lt;/A&gt;‌, &lt;A href="https://community.esri.com/migrated-users/2344"&gt;Gavin Rehkemper&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance one more time &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Sep 2019 05:47:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863263#M5577</guid>
      <dc:creator>Raul_Jimenez</dc:creator>
      <dc:date>2019-09-19T05:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: "Advanced" query selection of entities through a relationship</title>
      <link>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863264#M5578</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It&amp;nbsp;can be solved by &lt;STRONG&gt;creating a&amp;nbsp;Hosted Feature Layer View&lt;/STRONG&gt; using the &lt;A href="https://doc.arcgis.com/en/arcgis-online/analyze/join-features.htm"&gt;Join feature tool in Online&lt;/A&gt;.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;STRONG&gt;BTW:&lt;/STRONG&gt;&amp;nbsp;this analysis tool&amp;nbsp;takes no credits for analysis and storage when creating a Hosted View.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This way you create a hosted feature layer view that joins the two tables together and &lt;STRONG&gt;returns a new hosted layer&lt;/STRONG&gt;&amp;nbsp;(a new item). Things to bear in mind:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;As data changes in your source tables the data accessed via the view will always be up to date&lt;/LI&gt;&lt;LI&gt;As you will have the fields from both tables available you will be also able to filter by any combination of fields&lt;/LI&gt;&lt;/UL&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;STRONG&gt;Note:&lt;/STRONG&gt;&amp;nbsp;in order to create a hosted layer view you do need to own both tables.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks to &lt;A href="https://community.esri.com/migrated-users/3511"&gt;Jeremy Bartley&lt;/A&gt;‌ for your help!,&lt;/P&gt;&lt;P&gt;Raúl&lt;/P&gt;&lt;DIV style="position: absolute; left: 238px; top: 222px;"&gt;&lt;DIV class="gtx-trans-icon"&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2019 11:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/quot-advanced-quot-query-selection-of-entities/m-p/863264#M5578</guid>
      <dc:creator>Raul_Jimenez</dc:creator>
      <dc:date>2019-09-26T11:54:29Z</dc:date>
    </item>
  </channel>
</rss>

