|How to join two query results into a single one?||Sarpdoruk Tahmaz||1/22/13 6:03 AM|
Assume that my project is Facebook. I want to display a feed which consists of my status updates and my friends' status updates both.
Here are the relations;
This is how I get my friends status updates;
And this is how I get my own status updates;
Both queries work fine but I need a single query that combines these two.
Here is the StackOverflow link for the same question.
Thanks in advance.
|Re: How to join two query results into a single one?||Florian B.||1/22/13 6:21 AM|
I think you can work with optional relationship here:
|unk...@googlegroups.com||1/22/13 6:47 AM||<This message has been deleted.>|
|Re: How to join two query results into a single one?||Sarpdoruk Tahmaz||1/22/13 1:57 PM|
I did not realize that this query gives duplicates, it works well but provides duplicates in return. I guess, firstly it finds 0 level deep nodes then it traverses whole graph one more to find at most 1 level deep nodes. Here is the problem; at most 1 level deep means it includes 0 level deep nodes too so at the end there are 2 sets of 0 level deep nodes. I added DISTINCT to get rid of duplicates and it worked just fine, but if there are any other solution to duplicates without using duplicated I'd appreciate that too.
|Re: How to join two query results into a single one?||Florian B.||1/23/13 12:25 AM|
Mh what you can do is separate you query in two parts. First part get all nodes you want to check the status of, me and my friends. In the second part you get the status updates.
With the WITH statement you define which variables of the previous part should be used in the next part.
|Re: How to join two query results into a single one?||Sarpdoruk Tahmaz||1/23/13 2:25 AM|
That worked just fine. Thanks for the alterative solution using WITH statement.