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.
<Or>
</Or>
Elements and attributes
The following sections describe attributes, child elements, and parent elements.
Attributes
None
Child elements
- And
- BeginsWith
- Contains
- DateRangesOverlap
- Eq
- Geq
- Gt
- In
- Includes
- IsNotNull
- IsNull
- Leq
- Lt
- Membership
- Neq
- NotIncludes
- Or
Parent elements
Occurrences
- Minimum: 0
- Maximum: Unbounded
Remarks
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.
Examples
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>