Or element (Query)
Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013
Used within the Where element to group filters in a query.
Elements and attributes
The following sections describe attributes, child elements, and parent elements.
- Minimum: 0
- Maximum: Unbounded
This element can be nested inside other Or and And elements. The server supports unlimited complicated queries. However, any given Or element can have only two disjuncts; that is, only two child elements. If you need to disjoin three or more conditions, you must nest the Or elements, as demonstrated by the second example in the following section.
The following example performs a query for cases in which values of the Status field either do not equal Completed or are null. The results are sorted in descending order according to the Modified field.
<Query> <OrderBy> <FieldRef Name="Modified" Ascending="FALSE"></FieldRef> </OrderBy> <Where> <Or> <Neq> <FieldRef Name="Status"></FieldRef> <Value Type="Text"></Value> </Neq> <IsNull> <FieldRef Name="Status"></FieldRef> </IsNull> </Or> </Where> </Query>
The following example shows how to disjoin three conditions. Note that the first pair of conditions is within their own Or element, which is itself a condition of an outer Or element.
<Where> <Or> <Or> <Eq><FieldRef Name="LastName" /> <Value Type="Text">Bagel</Value> </Eq> <Eq><FieldRef Name="LastName" /> <Value Type="Text">Smith</Value> </Eq> </Or> <Includes> <FieldRef Name="Title" /><Value Type="Text">President</Value> </Includes> </Or> </Where>
Send feedback about: