SharePoint CAML Query AND/OR operators

camlsharepoint-2010

I would appreciate any help on getting my CAML query to work.
I have the following list:

| ID | Department | Status |

I am trying to get the query to return list items where ID=1, Department=Audit, and Status= "Stopped" OR "In Progress".

Can anyone please help?

Regards,

Best Answer

Query:

<Query>
   <Where>
      <And>
         <Eq>
            <FieldRef Name='ID' />
            <Value Type='Counter'>1</Value>
         </Eq>
         <And>
            <Eq>
               <FieldRef Name='Department' />
               <Value Type='Choice'>Audit</Value>
            </Eq>
            <Or>
               <Eq>
                  <FieldRef Name='Status' />
                  <Value Type='Choice'>In Progress</Value>
               </Eq>
               <Eq>
                  <FieldRef Name='Status' />
                  <Value Type='Choice'>Not Started</Value>
               </Eq>
            </Or>
         </And>
      </And>
   </Where>
</Query>

Note: it is assumed that Department is a Choice field


I would recommend you to utilize the tool that will help you build your CAML Queries, for example U2U Caml Query Builder

enter image description here

Related Topic