CAML Query Help

Mar 13, 2014 at 12:25 PM
Edited Mar 13, 2014 at 12:33 PM
I have this query:
CAMLQuery: "<Query>" +
"<OrderBy>" +
    "<FieldRef Name='ID' Ascending='FALSE'></FieldRef>" +
"</OrderBy>" +
"<Where>" +
    "<And>" +
        "<And>" +
            "<Contains>" +
                "<FieldRef Name='Column1' /><Value Type='Text'>" + newval + "</Value>" +
            "</Contains>" +
            "<Neq>" +
                "<FieldRef Name='Title' /><Value Type='Text'>" + curTitle + "</Value>" +
            "</Neq>" +
        "</And>" +
        "<Or>" +
            "<Contains>" +
                "<FieldRef Name='Column2' /><Value Type='Text'>" + newval + "</Value>" +
            "</Contains>" +
            "<Neq>" +
                "<FieldRef Name='Title' /><Value Type='Text'>" + curTitle + "</Value>" +
            "</Neq>" +
        "</Or>" +
    "</And>" +
"</Where>" +
"</Query>",
it throws no errors and only returns matching results from column1. I would like to it return matching results if either or both columns finds a match. Can anyone help?

Bob Mac
Mar 13, 2014 at 12:26 PM
Edited Mar 13, 2014 at 12:45 PM
Lol, I just figured it out. Posting it if anyone else is trying to do the same thing:
CAMLQuery: "<Query>" +
"<OrderBy>" +
    "<FieldRef Name='ID' Ascending='FALSE'></FieldRef>" +
"</OrderBy>" +
"<Where>" +
    "<And>" +
        "<Or>" +
            "<Contains>" +
                "<FieldRef Name='Column1' /><Value Type='Text'>" + newval + "</Value>" +
            "</Contains>" +
            "<Contains>" +
                "<FieldRef Name='Column2' /><Value Type='Text'>" + newval + "</Value>" +
            "</Contains>" +
        "</Or>" +
        "<Neq>" +
            "<FieldRef Name='Title' /><Value Type='Text'>" + curTitle + "</Value>" +
        "</Neq>" +
    "</And>" +
"</Where>" +
"</Query>",
Bob Mac