Share via


SPQuery returns all items of a list and ignors Where clause

I’ve just spend an hour trying to find the source why SPQuery returns all items of a list and ignors where clause

My code was like this:
SPQuery query = new SPQuery();
query.Query = "<Query><Where>---------</Where></Query>"
SPListItemCollection ListOneResults = ListOne.GetItems(query);

Sol'n: Just delete '<Query>' and '</Query>' tags from your query.Query.

I’d also like to thank U2U for their CAML Query Builder, which helps in writing the CAML queries.