Solved

Multiple OR operator in CAML?

Posted on 2010-09-01
3
721 Views
Last Modified: 2012-08-13
SELECT * FROM Applicants WHERE Position='a' or Position='b' or Position='c' or Position='d' or Position='f' or Position='g' or Position='h' or Position='i'

How to convert the above SQL to CAML?
0
Comment
Question by:PagodNaUtak
  • 2
3 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 33575163
Try:
<Where>
  <Or>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>a</Value></Eq>          
     <Eq><FieldRef Name='Position'/><Value Type='Text'>b</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>c</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>d</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>f</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>g</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>h</Value></Eq>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>i</Value></Eq>
  </Or>
</Where>

Open in new window

0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 33575227
Actually that probably won't work, you'll need to use nested OR's:

<Where>
  <Or>
     <Or>
        <Or>
           <Or>
              <Or>
                 <Or>
                    <Or>
                      <Eq><FieldRef Name='Position'/><Value Type='Text'>a</Value></Eq>          
                      <Eq><FieldRef Name='Position'/><Value Type='Text'>b</Value></Eq>
                    </Or>
                    <Eq><FieldRef Name='Position'/><Value Type='Text'>c</Value></Eq>
                 </Or>
                 <Eq><FieldRef Name='Position'/><Value Type='Text'>d</Value></Eq>
              </Or>
              <Eq><FieldRef Name='Position'/><Value Type='Text'>f</Value></Eq>
           </Or>
           <Eq><FieldRef Name='Position'/><Value Type='Text'>g</Value></Eq>
        </Or>
        <Eq><FieldRef Name='Position'/><Value Type='Text'>h</Value></Eq>
     </Or>
     <Eq><FieldRef Name='Position'/><Value Type='Text'>i</Value></Eq>
  </Or>
</Where>

Open in new window

0
 
LVL 8

Author Comment

by:PagodNaUtak
ID: 33575290
i will check and will give you feedback ASAP...
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question