I have 4 different lists with different fields.

Now I would like to retrieve items from all 4 of these lists ordered by user "Created By" ("Author") field using CAML.

Also, all of the lists have a common field "Cost" which I would like to retrieve from each item.

Is it possible to do this using just one CAML query?

  • No, you'll have to execute 4 queries and aggregate the results. It could be a single function as you are pulling the same data across them, but it would need to be parameterized so you can pass in the list name. Nov 17, 2016 at 14:50
  • Thought so... I guess that's what I'm going to do then. Any ideas on how to order all the results by user (Author)? Should I iterate the SPUsersCollection and then retrieve the items from all the lists for each user? @EricAlexander
    – Gintas K
    Nov 17, 2016 at 15:00
  • I'd use the promises framework to broadcast the calls, aggregate the results, and then reorder the result collection however you need. Here's a great example from Marc, sympmarc.com/2013/05/01/… Nov 17, 2016 at 15:23
  • Have you considered using search instead?
    – wjervis
    Nov 17, 2016 at 19:10
  • 1
    Could you post your code as answer for others to learn, tnx Nov 24, 2016 at 20:11

1 Answer 1


Answer to main question is no. But You can use SPSiteDataQuery with CAML query to define search criteria, for example:

SPSiteDataQuery spQuery = new SPSiteDataQuery
    Lists = "<Lists ServerTemplate=\"101\" />",
    Query = Camlex.Query().Where(i => i["Title"] == "test value").ToString(),
    ViewFields = Camlex.Query().ViewFields(new List<string> {"ID"}),
    RowLimit = 100
var dataTable = web.GetSiteData(spQuery);

foreach (DataRow datarow in dataTable.Rows)
    var listGuid = new Guid(datarow["ListId"]+"");
    var itemId = int.Parse(datarow["ID"]+"");

    // process items

This article explains the usage of SPSiteDataQuery.

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.