title: Are composite joins possible using FetchXml in Microsoft Dynamics CRM 4.0?
body: <p>I am using FetchXml to query CRM 4.0. We have a special case that will require a composite join between CRM entites. The <a href="http://msdn.microsoft.com/en-us/library/bb930489.aspx">FetchXml schema</a> indicates that multiple link-entity elements are allowed, and it also indicates that multiple filter/condition elements can be added to a link-entity. The problem I'm facing is that the value attribute of the  condition element does not appear to permit an entity/column name. It expects an explicitly declared value. </p>
  
  <p>For example, FetchXml lets you specify this:</p>
  
  <pre><code>&lt;link-entity name='myentity' from='column1' to='column2'/&gt;
  </code></pre>
  
  <p>... which does the T-SQL equivalent of this:</p>
  
  <pre><code>JOIN myentity on column1 = column2
  </code></pre>
  
  <p>And it lets you specify this:</p>
  
  <pre><code>&lt;link-entity name='myentity' from='column1' to='column2'&gt;
     &lt;filter type='and'&gt;
        &lt;condition attribute='column3' operator='eq' value='myvalue' /&gt;
     &lt;/filter&gt;
  &lt;/link&gt;
  </code></pre>
  
  <p>... which is the T-SQL equivalent of this:</p>
  
  <pre><code>JOIN myentity on column1 = column2 AND column3 = 'myvalue' 
  </code></pre>
  
  <p>FetchXml does not appear, however, to provide an equivalent of this:</p>
  
  <pre><code>JOIN myentity on column1 = column2 AND column3 = column4 
  </code></pre>
  
  <p>Note the difference. FetchXml provides for conditions in the join, but it does appear to provide for a composite join, that is, a join across multiple columns.</p>
  
  <p>Has anyone out there in cyberspace been able to perform a composite join using FetchXml in CRM 4.0? Thanks!</p>
  
  <p>More information:</p>
  
  <p>I'm hunting an answer that uses FetchXml to accomplish this - not SQL or the QueryExpression syntax. The SQL above is there just to explain the concept.</p>