<?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 Join multiple tables in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/join-multiple-tables/m-p/587492#M15889</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Forum,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do you join multiple tables?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully created a join between a table and a feature class and displayed the results in the table. I was also able to manipulate the displayed results by picking the fields in both tables that I wanted to display and highlighting and setting some fields to read only. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to do the same thing but add three more tables. There is existing relationship class between the tables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried this, but I don't think it's working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ITable f = GetTable(f);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type mrcfType = Type.GetTypeFromProgID("esriGeodatabase.MemoryRelationshipClassFactory");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMemoryRelationshipClassFactory mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer tgfl = (IGeoFeatureLayer)GetCurrentLayer("t", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass rc = mrcf.Open("MyReport", p as IObjectClass, "fid", tgfl.DisplayFeatureClass, "fid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDisplayRelationshipClass pDisplayRelClass = (IDisplayRelationshipClass)tgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(rc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer agfl = (IGeoFeatureLayer)GetCurrentLayer("a", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass arc = mrcf.Open("MyReport", f as IObjectClass, "aid", agfl.DisplayFeatureClass, "aid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)agfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(arc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer bgfl = (IGeoFeatureLayer)GetCurrentLayer("b", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass brc = mrcf.Open("MyReport", f as IObjectClass, "bid", bgfl.DisplayFeatureClass, "bid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)bgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(brc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer cgfl = (IGeoFeatureLayer)GetCurrentLayer("c", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass crc = mrcf.Open("MyReport", f as IObjectClass, "cid", cgfl.DisplayFeatureClass, "cid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)cgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(crc, esriJoinType.esriLeftOuterJoin);
&lt;/PRE&gt;&lt;SPAN&gt;The first join is between a table (p) and a feature class (t) where t is one and p is many. The results should be stored in the table p.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (a) and feature class (t) where a is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (b) and feature class (t) where b is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (c) and feature class (t) where c is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to be able to instantiate IStandaloneTable from IDisplayRelationshipClass and specifically set IStandaloneTable.Table I'm assuming this would be the table used to create the join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once that's working I can perform queries on the joined data and extract what I need and display it how I want using the same procedures as I've used before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've looked at the following &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=992&amp;amp;t=53773&amp;amp;mc=6#msgid329134" rel="nofollow noopener noreferrer" target="_blank"&gt;old thread&lt;/A&gt;&lt;SPAN&gt; but I'm not certain I have things defined correctly. Apparently there were some changes that needed to be made to the function. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;G&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:14:48 GMT</pubDate>
    <dc:creator>GregRieck</dc:creator>
    <dc:date>2021-12-12T01:14:48Z</dc:date>
    <item>
      <title>Join multiple tables</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/join-multiple-tables/m-p/587492#M15889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Forum,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do you join multiple tables?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have successfully created a join between a table and a feature class and displayed the results in the table. I was also able to manipulate the displayed results by picking the fields in both tables that I wanted to display and highlighting and setting some fields to read only. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to do the same thing but add three more tables. There is existing relationship class between the tables.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried this, but I don't think it's working.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ITable f = GetTable(f);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Type mrcfType = Type.GetTypeFromProgID("esriGeodatabase.MemoryRelationshipClassFactory");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IMemoryRelationshipClassFactory mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer tgfl = (IGeoFeatureLayer)GetCurrentLayer("t", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass rc = mrcf.Open("MyReport", p as IObjectClass, "fid", tgfl.DisplayFeatureClass, "fid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IDisplayRelationshipClass pDisplayRelClass = (IDisplayRelationshipClass)tgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(rc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer agfl = (IGeoFeatureLayer)GetCurrentLayer("a", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass arc = mrcf.Open("MyReport", f as IObjectClass, "aid", agfl.DisplayFeatureClass, "aid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)agfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(arc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer bgfl = (IGeoFeatureLayer)GetCurrentLayer("b", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass brc = mrcf.Open("MyReport", f as IObjectClass, "bid", bgfl.DisplayFeatureClass, "bid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)bgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(brc, esriJoinType.esriLeftOuterJoin);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IGeoFeatureLayer cgfl = (IGeoFeatureLayer)GetCurrentLayer("c", 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mrcf = (IMemoryRelationshipClassFactory)Activator.CreateInstance(mrcfType);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IRelationshipClass crc = mrcf.Open("MyReport", f as IObjectClass, "cid", cgfl.DisplayFeatureClass, "cid", "forward", "backward", esriRelCardinality.esriRelCardinalityOneToMany);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass = (IDisplayRelationshipClass)cgfl;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pDisplayRelClass.DisplayRelationshipClass(crc, esriJoinType.esriLeftOuterJoin);
&lt;/PRE&gt;&lt;SPAN&gt;The first join is between a table (p) and a feature class (t) where t is one and p is many. The results should be stored in the table p.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (a) and feature class (t) where a is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (b) and feature class (t) where b is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The next join is between a feature class (c) and feature class (t) where c is one and t is many.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to be able to instantiate IStandaloneTable from IDisplayRelationshipClass and specifically set IStandaloneTable.Table I'm assuming this would be the table used to create the join.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once that's working I can perform queries on the joined data and extract what I need and display it how I want using the same procedures as I've used before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've looked at the following &lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=93&amp;amp;f=992&amp;amp;t=53773&amp;amp;mc=6#msgid329134" rel="nofollow noopener noreferrer" target="_blank"&gt;old thread&lt;/A&gt;&lt;SPAN&gt; but I'm not certain I have things defined correctly. Apparently there were some changes that needed to be made to the function. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;G&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:14:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/join-multiple-tables/m-p/587492#M15889</guid>
      <dc:creator>GregRieck</dc:creator>
      <dc:date>2021-12-12T01:14:48Z</dc:date>
    </item>
  </channel>
</rss>

