Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

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

share|improve this answer
add comment

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>";
share|improve this answer
    
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 Dec 26 '12 at 7:59
    
I updated my answer –  Alexander Dec 26 '12 at 8:54
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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