1

I have requestID, date column in 4 different lists. I want to build a webpart which shows user requests of different types therefore i need to query multiple lists with column requestID and date.

How to retrieve combined data from multiple lists using CAML?

3 Answers 3

3

you can use SPSiteDataQuery. Also you can try to use OOTB content query web part.

from link above

query.Lists = "<Lists><List ID='7A9FDBE6-0841-430a-8D9A-53355801B5D5' /><List ID='3D18F506-FCA1-451e-B645-2D720DC84FD8' /></Lists>";
2
  • Alexander sorry about the late reply I was out of town. Can you give me an example how to use SPSiteDataQuery for more then 1 list querY?
    – user342944
    Commented Dec 26, 2012 at 7:59
  • I updated my answer
    – Alexander
    Commented Dec 26, 2012 at 8:54
1

CAML won't help me to achieve what i want. Just came across this solution..worked perfectly and exactly what i was looking for..yes LINQ is the answer.

http://msdn.microsoft.com/en-us/library/ff742311(v=office.14).aspx

0

First of all is there some kind of a link between those lists or are they totaly independent and have nothing in common?

In this case you should just retrieve the lists one by one and query the the items you need then you can the retrieved SPListItemCollection insert in DataTable or in an object and do what you want to do. So combining data after retrieval should also happen manually as if there are different content types, you want have the same result ... etc et

In any case I doubt you can write like one CAML query which will retrieve from lists same value, it is not like SQL query or something where you can say from table1, table2, table3 for example.

I hope this gave you an idea, so basically query for each lists seperatly. Maybe there are different approaches but i don't know them.

Happy coding

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.