From: | Robert DiFalco <robert(dot)difalco(at)gmail(dot)com> |
---|---|
To: | David G Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Combining two queries |
Date: | 2014-12-18 22:02:42 |
Message-ID: | CAAXGW-zsAyN9PEtoEojXgvqUWS+WWsGcaWmO0oDVv07KW2dffw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is the intersect any better than what I originally showed? On the ROW
approach, I'm not sure where the context for that is coming from since it
may not be in the intersection. Consider n1 and n2 are NOT friends but they
have >0 mutual friends between them.
On Thu, Dec 18, 2014 at 1:29 PM, David G Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> Robert DiFalco wrote
> > For 2 arbitrary ids, I need a query to get two pieced of data:
> > * Are the two users friends?
>
> This seems easy...ROW(u_id, f_id) = ROW(n1, n2)
>
>
> > * How many friends do the two users have in common.
>
> SELECT f_id FROM [...] WHERE u_id = n1
> INTERSECT
> SELECT f_id FROM [...] WHERE u_id = n2
>
> Put those into WITH/CTE and use the main query to combine them in whatever
> way seems appropriate.
>
> David J.
>
>
>
>
> --
> View this message in context:
> http://postgresql.nabble.com/Combining-two-queries-tp5831378p5831391.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | David Johnston | 2014-12-18 22:07:48 | Re: Combining two queries |
Previous Message | John McKown | 2014-12-18 21:51:58 | Re: Combining two queries |