CAML Query with more than two conditions


<View>
    <Query>
        <Where>
            <And>
                <And>
                    <Eq>
                        <FieldRef Name='Brand' />
                        <Value Type='Lookup'>" + brand + "</Value>
                    </Eq>                            
                    <Eq>"
                        <FieldRef Name='SiteType' />
                        <Value Type='Lookup'>" + site + "</Value>
                    </Eq>
                </And>
            <Eq>"
                <FieldRef Name='State' />
                <Value Type='Lookup'>" + changedState + "</Value>
            </Eq>
            </And>
        </Where>
    </Query>
    <ViewFields>
        <FieldRef Name='Title'/>
        <FieldRef Name='ID'/>
    </ViewFields>
</View>

When you want to use more than two conditions when selecting items using CAML, use the above approach.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.