0

How to create CAML query to find items which have all specified lookup values?

The query below returns items which have item1 or item2, or (item1 and item2). But I would like to return only items which have (item1 and item2)

<Where>
  <And>
     <Eq>
        <FieldRef Name='Column1' />
        <Value Type='LookupMulti'>item1</Value>
     </Eq>
     <Eq>
        <FieldRef Name='Column1' />
        <Value Type='LookupMulti'>item2</Value>
     </Eq>
  </And>
</Where>
1
  • Actually it is working as expected. There was an typo in CAML query. Commented Jan 10, 2018 at 9:00

1 Answer 1

0

Try the following caml got from CAML Designer:

 <Where>
      <And>
         <Eq>
            <FieldRef Name='lookuptest' />
            <Value Type='LookupMulti'>China</Value>
         </Eq>
         <Eq>
            <FieldRef Name='lookuptest' />
            <Value Type='LookupMulti'>USA</Value>
         </Eq>
      </And>
   </Where>

To avoid wrong type or spelling, I would highly recommend to use CAML Designer to build CAML Query: enter image description here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.