SharePoint - Can we use joins in CQWP in SharePoint2010?

Asked By Nani gandham on 05-Mar-12 10:02 AM
Earn up to 20 extra points for answering this tough question.

Hi All,

Can we use joins in CQWP in SharePoint2010? if we can then what are the ways to do that.

can we fetch the data from two different lists based on a condition using CQWP?

what is the best way to query the data using CQWP? SPQuery or SPSiteDataQuery or CrosslistQuery.


Any help would be appreciated.

By

Nani

[)ia6l0 iii replied to Nani gandham on 05-Mar-12 12:07 PM
If you need to join two lists - then you can't use CAML. They do not support it.

The only way I know is to create a linked datasource and "join" the contents of the data sources(lists). 

This is explained very well in this post

Hope this helps.
D Company replied to [)ia6l0 iii on 05-Mar-12 12:59 PM
Hello,

The Content Query Web Part allows you to aggregate content from a particular List(but as mentioned in previous post not using join on two lists), Site or the whole Site Collection. You can query the content of particular type and filter it using various criteria.

Here is the best example given which helps u to achieve your goal

and MSDN tells in more detail



Regards
D
kalpana aparnathi replied to Nani gandham on 05-Mar-12 02:05 PM
hi,

You may want to consider the Data Form Web Part (DFWP) as an alternative to the CQWP, given the constraints you are asking for. The DFWP allows for the creation of XSL that will allow you to filter information as you have described. It also allows for more advanced things like conditional formatting, data source joins, etc.


The best way to see if this would work for you is to use SharePoint Designer to generate a Data Source from your list and then conditionally format it using the GUI to generate your basic XSL - it may well be that you never actually have to touch the XSL code, but it is there if you need it. Start with the major objectives, working your way down to the minor ones, saving working copies often. The created DFWP can simply be exported to save multiple copies along the way.


http://blog.sharepointcookbook.com


Regards,
[)ia6l0 iii replied to D Company on 05-Mar-12 09:37 PM
I think you mistakenly replied to me. 

Nevertheless, the content query wp allows you to aggreate, but I spoke about using CAML queries to perform joins. I hope you see the difference. And incidentally, the link that you suggested the OP to read also talks about using "Linked Sources" which is what I suggested at the first place.

 

Somesh Yadav replied to Nani gandham on 06-Mar-12 02:04 AM
How about using an DVWP for this, you can create a joined datasource and use the DVWP to present the result. There's plenty blogs around, and one of the is:  http://www.manliane.com/kb/432/

D Company replied to [)ia6l0 iii on 06-Mar-12 10:03 AM
Yup.

Sorry,by Mistake i replied to you. Thanks for your  coordination.


D