Joins Element (View)
Last modified: November 19, 2009
Applies to: SharePoint Foundation 2010
Contains Join elements needed for a query.
The following is an example of a Joins element with two left outer joins. CustomerName is a lookup field on an Orders list. It looks up to the ID field of a Customers list. The Customer list, in turn, has a CityName field that is a lookup field to a Cities list. The first Join element assigns ‘customers’ as an alias for the Customers list. The Eq element child defines the join using the same source and target fields that constitute the lookup relation. The second Join element assigns ‘customerCities’ as an alias to the Cities list. It defines the join in parallel to the existing lookup relation between the Customer and Cities lists.
Aliases are needed for the lists because there can be more than one join to the same list and different aliases are needed to differentiate the joins. For example, in addition to the joins from Orders to Customer and from Customer to Cities, there could also be joins from Orders to Suppliers and from Suppliers to Cities. In the case of the last join, a different alias, say ‘supplierCities’, would be assigned to the Cities list from the one that is used for the Customer to Cities join.
<Joins> <Join Type=’LEFT’ ListAlias=’customers’> <Eq> <FieldRef Name=’CustomerName’ RefType=’Id’ /> <FieldRef List=’customers’ Name=’ID’ /> </Eq> </Join> <Join Type=’LEFT’ ListAlias=’customerCities’> <Eq> <FieldRef List=’customer’ Name=’CityName’ RefType=’Id’ /> <FieldRef List=’customerCities’ Name=’ID’ /> </Eq> </Join> </Joins>