Skip to content

Latest commit

 

History

History
145 lines (118 loc) · 3.6 KB

and-element-query.md

File metadata and controls

145 lines (118 loc) · 3.6 KB
titlemanagerms.datems.audiencems.topicms.localizationpriorityapi_nameapi_typems.assetiddescription
And element (Query)
soliver
3/9/2015
Developer
reference
medium
Query schema
schema
d71502b2-7f7d-4bd9-9a94-70848d85b24a
In CAML, used within the Where element to group filters in a query for a view.

And 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 for a view.

<And> </And>

Elements and attributes

The following sections describe attributes, child elements, and parent elements.

Attributes

None

Child elements

Parent elements

Occurrences

  • Minimum: 0
  • Maximum: Unbounded

Remarks

This element can be nested inside other And and Or elements. The server supports unlimited complicated queries. However, any given And element can have only two conjuncts; that is, only two child elements. If you need to conjoin three or more conditions, you must nest the And elements, as demonstrated by the third example in the following section.

Examples

The following example conveys criteria for a query on the ProductID field: (ProductID = J1539 AND ProductID = J9862) AND (ProductID = J0394 OR ProductID = J4589).

<And> <And> <Eq> <FieldRefName="ProductID"/> <ValueType="Text">J1539</Value> </Eq> <Eq> <FieldRefName="ProductID"/> <ValueType="Text">J9862</Value> </Eq> </And> <Or> <Eq> <FieldRefName="ProductID"/> <ValueType="Text">J0394</Value> </Eq> <Eq> <FieldRefName="ProductID"/> <ValueType="Text">J4589</Value> </Eq> </Or> </And>

The following example performs a query for cases in which values of the Status field do not equal Completed and values of the Sent field are null. The records returned are sorted in descending order according to values of the Modified field.

<Query> <OrderBy> <FieldRefName="Modified"Ascending="FALSE"></FieldRef> </OrderBy> <Where> <And> <Neq> <FieldRefName="Status"></FieldRef> <ValueType="Text">Completed</Value> </Neq> <IsNull> <FieldRefName="Sent"></FieldRef> </IsNull> </And> </Where> </Query>

The following example shows how to conjoin three conditions. Note that the first pair of conditions is within their own And element, which is itself a condition of an outer And element.

<Where> <And> <And> <Eq><FieldRefName="LastName" /> <ValueType="Text">Bagel</Value> </Eq> <Eq><FieldRefName="FirstName" /> <ValueType="Text">Jean</Value> </Eq> </And> <Includes> <FieldRefName="Title" /><ValueType="Text">President</Value> </Includes> </And> </Where> 

close