问题
I have this table
Col1 | Col2 | Col3
1 MeYou | You | Them
2 Them | They | You
3 Them | Me | They
4 They | Us | We
5 Us | Them | MeAsk
I would like to do these Query
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'
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.
My question is how am I going to compose this kind of query in CAML query for my sharepoint apps?
Thanks in advance :)
回答1:
First Query
<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>
second Query
<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>
来源:https://stackoverflow.com/questions/5255143/need-help-on-building-caml-query