$caml = '<Where><AND><Neq><FieldRef Name="marking" />
<Value Type="Text">Off-S</Value></Neq><Neq><FieldRef Name="marking" />
<Value Type="Text">Off</Value></Neq></AND></Where>'

I have this query, which doesn't return anything. What I want is it to return all the items that are in the column marking that are not equal to Off-S and Off

  • 2
    Stop hand writing CAML queries, when a great tool such as CamlDesigner exists (camldesigner.com)
    – MdMazzotti
    Commented Jun 12, 2014 at 12:48

4 Answers 4


Your <And> tag is in all caps; CAML is case sensitive. Try this:

            <FieldRef Name="marking" />
            <Value Type="Text">Off-S</Value>
            <FieldRef Name="marking" />
            <Value Type="Text">Off</Value>

And like MdMazzotti said, use a tool to build your CAML queries.


CAML keywords are case-sensitive, try writing "And" instead of "AND".


I use a caml query tool called U2U Caml query. Its free and easy. http://www.u2u.be/Software


Have you tried :

$caml = '<Where><AND><Or><Neq><FieldRef Name="marking" />
<Value Type="Text">Off-></Value></Neq><Or><Neq><FieldRef Name="marking" />
<Value Type="Text">Off</Value></Neq></Or></Or></AND></Where>'

maybe this helps you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.