我有这张桌子
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行,即row5。
我的问题是我如何在CAML查询中为我的sharepoint应用程序撰写此类查询?
提前致谢:)
答案 0 :(得分:1)
第一次查询
<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>