Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5971693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:33:07+00:00 2026-05-22T20:33:07+00:00

I am working on proof-of-concept code to dynamically generate CAML based on keywords provided

  • 0

I am working on proof-of-concept code to dynamically generate CAML based on keywords provided to a highly-specific search web service that I am writing. I am not using the SharePoint-provided search web service for this proof. I have done so already for what I am trying to achieve. From all of my research, I cannot find a close example for what I am trying to achieve, which is to check multiple fields for multiple values. Yes, I have looked on SO already for my answer, including this one: Need help on building CAML Query.

With that said, if it is possible, how can the following SQL-like query be written in CAML?

SELECT FirstName, LastName, Description, Profile
FROM SomeFakeTable
WHERE (FirstName = 'John' OR LastName = 'John' OR Description = 'John' OR Profile='John')
  AND (FirstName = 'Doe' OR LastName = 'Doe' OR Description = 'Doe' OR Profile='Doe')
  AND (FirstName = '123' OR LastName = '123' OR Description = '123' OR Profile='123')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T20:33:07+00:00Added an answer on May 22, 2026 at 8:33 pm

    Since you are not allowed to put more than two conditions in one condition group (And | Or) you have to create an extra nested group (MSDN). The expression A AND B AND C looks like this:

    <And>
        A
        <And>
            B
            C
        </And>
    </And>
    

    Your SQL like sample translated to CAML (hopefully with matching XML tags 😉 ):

    <Where>
        <And>
            <Or>
                <Eq>
                    <FieldRef Name='FirstName' />
                    <Value Type='Text'>John</Value>
                </Eq>
                <Or>
                    <Eq>
                        <FieldRef Name='LastName' />
                        <Value Type='Text'>John</Value>
                    </Eq>
                    <Eq>
                        <FieldRef Name='Profile' />
                        <Value Type='Text'>John</Value>
                    </Eq>
                </Or>
            </Or>
            <And>       
                <Or>
                    <Eq>
                        <FieldRef Name='FirstName' />
                        <Value Type='Text'>Doe</Value>
                    </Eq>
                    <Or>
                        <Eq>
                            <FieldRef Name='LastName' />
                            <Value Type='Text'>Doe</Value>
                        </Eq>
                        <Eq>
                            <FieldRef Name='Profile' />
                            <Value Type='Text'>Doe</Value>
                        </Eq>
                    </Or>
                </Or>
                <Or>
                    <Eq>
                        <FieldRef Name='FirstName' />
                        <Value Type='Text'>123</Value>
                    </Eq>
                    <Or>
                        <Eq>
                            <FieldRef Name='LastName' />
                            <Value Type='Text'>123</Value>
                        </Eq>
                        <Eq>
                            <FieldRef Name='Profile' />
                            <Value Type='Text'>123</Value>
                        </Eq>
                    </Or>
                </Or>
            </And>
        </And>
    </Where>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project that's been accepted as a proof of concept and
I am working on a proof of concept for some workflow automation using Exchange
I'm new mobile development and i'm working on an proof of concept application on
Simple issue. I'm working on a proof-of-concept for an application with additional database connection,
In a proof-of-concept project I'm working on, I have a generic abstract class that
I'm working on a sort of proof-of-concept for a project that approximates Firebug's inspector
Working in Eclipse on a Dynamic Web Project (using Tomcat (v5.5) as the app
Working with MVC3, Razor, Jquery, Javascript. The below code loops through and displays a
Working code: if ( $check1 eq $search_key ... Previous 'buggy' code: if ( $check1
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.