SharePoint CAML Query AND/OR operators

15,100

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

Share:
15,100
user3586514
Author by

user3586514

Updated on June 13, 2022

Comments

  • user3586514
    user3586514 almost 2 years

    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,

  • user3586514
    user3586514 almost 10 years
    Thank you very much for the solution. Very handy tool