在构建 CAML 查询方面需要帮助 [英] Need help on building CAML Query

查看:49
本文介绍了在构建 CAML 查询方面需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这张桌子

    Col1  | Col2  | Col3
 1  MeYou | You   | Them
 2  Them  | They  | You
 3  Them  | Me    | They
 4  They  | Us    | We
 5  Us    | Them  | MeAsk

我想做这些查询

Select all rows from MyTable 
Where Col1 contains 'Me' or Col2 contains 'Me' or Col3 contains 'Me'

Select all rows from MyTable 
Where (Col1 contains 'Me' or Col3 contains 'Me') and Col2 equals to 'Them'

根据显示的表格并使用我想要的查询条件,查询 1 应该得到 3 行作为回报.返回的行必须是 row1、row3 和 row5.查询 2 应该只得到 1 行作为回报,即第 5 行.

Based on the table shown and using the condition that I wanted on my query, Query 1 should get 3 rows in return. The returned rows must be row1, row3 and row5. Query 2 should get only 1 row in return and that is row5.

我的问题是我将如何在 CAML 查询中为我的 Sharepoint 应用编写此类查询?

My question is how am I going to compose this kind of query in CAML query for my sharepoint apps?

提前致谢:)

推荐答案

第一次查询

<Where>
  <Or>
     <Contains>
        <FieldRef Name='Col1' />
        <Value Type='User'>22</Value>
     </Contains>
     <Or>
        <Contains>
           <FieldRef Name='Col2' />
           <Value Type='User'>22</Value>
        </Contains>
        <Contains>
           <FieldRef Name='Col3' />
           <Value Type='User'>22</Value>
        </Contains>
     </Or>
  </Or>
</Where>

第二次查询

<Where>
    <Or>
        <Contains>
            <FieldRef Name="Col1" /> 
            <Value Type="User">22</Value>
        </Contains>
        <And>
            <Contains>
                <FieldRef Name="Col2" /> 
                <Value Type="User">23</Value>
            </Contains>
            <Contains>
                <FieldRef Name="Col3" /> 
                <Value Type="User">22</Value>
            </Contains>
        </And>
    </Or>
</Where>

这篇关于在构建 CAML 查询方面需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆