5

How do i do a left join using FetchXml?

Consider a simple SQL query like the following:

select person.name, address.city from person
left join address on person.addressid = address.addressid

How would something simple like this be done using FetchXml? Currently my FetchXml query looks like the following:

<fetch mapping='logical'>
  <entity name='person'>
    <attribute name='name' />
    <link-entity name='address' from='addressid' to='addressid'>
      <attribute name='city' />
    </link-entity>
  </entity>
</fetch>
avolkmann
  • 2,962
  • 2
  • 19
  • 27
Luke Baulch
  • 3,626
  • 6
  • 36
  • 44

1 Answers1

11

Update your <link-entity> like so:

<link-entity name='address' from='addressid' to='addressid' link-type='outer'>
Matt
  • 4,656
  • 1
  • 22
  • 32