3.1.4.9.3.1 Where Format

The Where clause specifies the criteria governing which list items are returned by the GetListItems method. The Where clause MUST be well-formed XML and MUST comply with the XML schema definition (XSD) schema specified in [MS-WSSCAML].

An example of a well-formed Where clause follows.

 <Where >
     <And >
         <Contains >
             <FieldRef Name='Title'>
             </FieldRef>
             <Value Type='Text'>Red</Value>
         </Contains>
         <Gt >
             <FieldRef Name='ID'>
             </FieldRef>
             <Value Type='Counter'>0</Value>
         </Gt>
     </And>
 </Where>

The ANSI-SQL language equivalent of this criterion would be:

 WHERE Title LIKE ''%Red%' AND ID > 0 

The Where clause can contain an arbitrary number of conditions, joined into And/Or groups if more than one condition is defined. Each And/Or group MUST contain two elements – each being either condition or nested And/Or group.

Each condition consists of a Predicate, a FieldRef element, and a Value of the appropriate type, where:

  • Predicate specifies the comparison, such as Eq, Get, or Le, as specified in the complete XSD in [MS-WSSCAML].

  • FieldRef element is a reference to one of the fields. FieldRef name attribute MUST be a valid field name. Valid field names are provided in the Name attribute of the _sProperty element (see section 3.1.4.7.3.3) returned from the GetList operation.

  • Value of appropriate type suitable to be compared using the Predicate with the field in question. Two predicates (IsNull and IsNotNull) do not require a value for comparison.