>>I have a table called friends with a user_id and a friend_id (both of these
>>relate to an id in a users table).
>>For each friend relationship there are two rows. There are currently ONLY
>>reciprocal relationships. So if user ids 1 and 2 are friends there will be
>>two rows (1,2) and (2,1).
>I have a table called friends with a user_id and a friend_id (both of these
>relate to an id in a users table).
>For each friend relationship there are two rows. There are currently ONLY
>reciprocal relationships. So if user ids 1 and 2 are friends there will be two
>rows (1,2) and (2,1).
>For
The INNER JOIN to itself with a count turns out to have a lower cost query
plan than the INTERSECT approach. On the ROW approach, it also seems to
take longer than the simple EXISTS query. But I suppose I can put both of
those into CTEs for convenience. I guess I was just hoping there was a
lower c
On Thu, Dec 18, 2014 at 1:57 PM, Robert DiFalco
wrote:
> Thanks! So how would I combine them so that I would get a single row with
> the mutual friend count and isFriends for a given pair of users? I can't
> figure out how to modify what you've posted so that it gives the results
> like the compou
On Thu, Dec 18, 2014 at 3:02 PM, Robert DiFalco
wrote:
> 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
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
Wow, I sure went overboard with the "friendship chain" thought. I don't
know where I got the idea that was your question.
On Thu, Dec 18, 2014 at 3:46 PM, John McKown
wrote:
>
> On Thu, Dec 18, 2014 at 2:10 PM, Robert DiFalco
> wrote:
>
>> I have a table called friends with a user_id and a frien
On Thu, Dec 18, 2014 at 2:10 PM, Robert DiFalco
wrote:
> I have a table called friends with a user_id and a friend_id (both of
> these relate to an id in a users table).
>
> For each friend relationship there are two rows. There are currently ONLY
> reciprocal relationships. So if user ids 1 and
On Thu, Dec 18, 2014 at 12:10 PM, Robert DiFalco
wrote:
> I have a table called friends with a user_id and a friend_id (both of these
> relate to an id in a users table).
>
> For each friend relationship there are two rows. There are currently ONLY
> reciprocal relationships. So if user ids 1 and
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 [...
I have a table called friends with a user_id and a friend_id (both of these
relate to an id in a users table).
For each friend relationship there are two rows. There are currently ONLY
reciprocal relationships. So if user ids 1 and 2 are friends there will be
two rows (1,2) and (2,1).
For 2 arbit
If you want to return rows with zeros, you may need to do something like
this:
select b.name as viewer, count(viewerid)
from xenons b left join viewer_movies a on (b.id = a.viewerid)
group by b.name
Eddy Macnaghten wrote:
select b.name as viewer, count(*)
from viewer_movies a, xenons b
where b.id
select b.name as viewer, count(*)
from viewer_movies a, xenons b
where b.id = a.viewerid
group by b.name
On Sat, 2004-10-23 at 00:55, Mark Harrison wrote:
> How can I combine these two queries?
>
> # select viewerid,count(*) from viewer_movies group by viewerid order by viewerid;
> viewerid |
Title: RE: [GENERAL] combining two queries?
Try
select a.name,count(*) from
xenons as a,
viewer_movies as b
where a.id = b.viewerid
group by a.name order by a.name;
-Original Message-
From: Mark Harrison [mailto:[EMAIL PROTECTED]]
Sent: Friday, October 22, 2004 4:55 PM
To: [EMAIL
How can I combine these two queries?
# select viewerid,count(*) from viewer_movies group by viewerid order by viewerid;
viewerid | count
--+
22964835 | 3055
22964836 | 1291
22964837 | 3105
22964838 |199
planb=# select name from xenons where id = 23500637;
name
15 matches
Mail list logo