1

I have the first query:

  queryMuaj.Query = "<OrderBy>" +
                          "<FieldRef Name ='testb' Ascending = 'TRUE'/>" +
                    "</OrderBy>" +
                    "<Where>" +
                    "<And>" +
                          "<Geq>" +
                           "<FieldRef Name='testb' />" +
                              "<Value Type='DateTime' IncludeTimeValue='FALSE'>" + startDateFx + "</Value>" +
                          "</Geq>" +
                          "<Leq>" +
                              "<FieldRef Name='testb' />" +
                              "<Value Type='DateTime' IncludeTimeValue='FALSE'>" + endDatFx + "</Value>" +
                          "</Leq> " +
                    "</And>" +
                    "</Where>";

And I have the second qyery:

    query.Query = @"<Where><Eq>
                     <FieldRef Name='Team' />
                     <Value Type='Text'>" + selvalcomp+ @"</Value>
                  </Eq></Where>"

And I want to merge the 2 queries into a single query how can I do this? HELP ME PLEASE

Thanks.

2

2 Answers 2

2
queryMuaj.Query = "<OrderBy>" +
                          "<FieldRef Name ='testb' Ascending = 'TRUE'/>" +
                    "</OrderBy>" +
                    "<Where>" +
                    "<And>"+    
                       "<And>" +
                            "<Geq>" +
                            "<FieldRef Name='testb' />" +
                               "<Value Type='DateTime' IncludeTimeValue='FALSE'>" + startDateFx + "</Value>" +
                            "</Geq>" +
                            "<Leq>" +
                               "<FieldRef Name='testb' />" +
                                "<Value Type='DateTime' IncludeTimeValue='FALSE'>" + endDatFx + "</Value>" +
                            "</Leq> " +
                      "</And>" +
                      "<Eq>"+
                         "<FieldRef Name='Team' />"+
                         "<Value Type='Text'>" + selvalcomp+ "</Value>" +
                     "</Eq>"+
                   "</And>"+    
                   "</Where>";

Check my answer on how to write nested query

2

Try this query:

<OrderBy> <FieldRef Name ='testb' Ascending = 'TRUE'/> </OrderBy>
    <Where>
    <And>
    <Eq><FieldRef Name='Team' /><Value Type='Text'>" + selvalcomp+ "</Value></Eq>
    <And>
    <Geq><FieldRef Name='testb' /><Value Type='DateTime' IncludeTimeValue='FALSE'>" + startDateFx + "</Value></Geq>
    <Leq><FieldRef Name='testb' /><Value Type='DateTime' IncludeTimeValue='FALSE'>" + endDatFx + "</Value></Leq></And>
    </And>
    </Where>

Get some reference from this link about nest conditions in CAML query.

2
  • in my list for team I have a dropdown menu and it shows me nothing why? Commented Jul 7, 2016 at 8:50
  • Please ask a new question or describe your problem properly in question for better understand. Commented Jul 7, 2016 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.