Faves in common

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- Faves in common

create table #MyFaves
(
 PostId int
)

insert into #MyFaves
select
 v.PostId as PostId
from Votes v
where v.VoteTypeId = 5
and v.UserId = ##UserId##

create table #TheirFaves
(
 PostId int
)

insert into #TheirFaves
select
 v.PostId as PostId
from Votes v
where v.VoteTypeId = 5
and v.UserId = 8745

select
 p.Id as [Post Link]
from Posts p
where
(select count(*) from #MyFaves mf where mf.PostId = p.Id) = 1 and
(select count(*) from #TheirFaves mf where mf.PostId = p.Id) = 1

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results