Query Element (Query)

Defines the query for a view.

<Query>
  <Where>
    ...
    </Where>
  <GroupBy>
    ...
    </GroupBy>
  <OrderBy>
    ...
    </OrderBy>
</Query>
Attributes

Attribute Description

None

N/A

Child Elements

Parent Elements

Occurrences

Minimum: 0

Maximum: 1

Example

The following example queries the Status field for cases where the value does not equal Completed or is null, returning the results according to a descending sort on the Modified field. The Where element contains an Or element to group the filters.

Xml
<Query>
  <OrderBy>
    <FieldRef Name="Modified" Ascending="FALSE"></FieldRef>
  </OrderBy>
  <Where>
    <Or>
      <Neq>
        <FieldRef Name="Status"></FieldRef>
        <Value Type="Text">Completed</Value>
      </Neq>
      <IsNull>
        <FieldRef Name="Status"></FieldRef>
      </IsNull>
    </Or>
  </Where>
</Query>
Tags :


Community Content

S.B.Rogers
Understanding CAML Query
Think of it as reverse polish logic, remember the HP calculators where you entered 4, 5, + and the answer was 9.

enter variable1, value1, eq, variable2, value2, eq, and, where, now reverse the order
to get
<where>
<and>
<eq> variable1, value1 </eq>
<eq> variable2, value2 </eq>
</and>
</where>

which is equal to

select * from list
where variable1 = value1 and variable2 = value2

Tags : caml query

Page view tracker