In a slight mental tangle and I expect this is easier than I imagine.
Got the following tables:
create table #x
(
handid int,
cardid int
)
insert into #x
values
(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),
(2,2),(2,3),(2,4),(2,300),(2,400),(2,500),(2,8),
(3,2),(3,3),(3,4),(3,300),(3,400),(3,7),(3,8),
(4,2),(4,300),(4,400),(4,500),(4,6),(4,7),(4,8)
create table #winners(cardid int)
insert into #winners values(300),(400),(500)
select a.*
from
#x a
inner join #winners b
on
a.cardid = b.cardid
This returns the following:

I only want this query to return the rows when all of the three cardids exists for a handid. So the desired result set would not include handid 3.
This is a model of reality.
In reality #x contains 500 mill records.
EDIT
Ok – there are actually winners that are made up of sets of data from #winners which have a variable number of records. So amending the original code to the following the result set should not include handId 1 or handId 3. I am also getting some unwanted duplicate records in the result set:
create table #x
(
handid int,
cardid int
)
insert into #x
values
(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8000),
(2,2),(2,3),(2,4),(2,300),(2,400),(2,500),(2,8),
(3,2),(3,3),(3,4),(3,300),(3,400),(3,7),(3,8),
(4,2),(4,300),(4,400),(4,500),(4,6),(4,7),(4,8)
create table #winners(winningComb char(1), cardid int)
insert into #winners values('A',300),('A',400),('A',500),('B',8000),('B',400)
select a.*
from
#x a
inner join #winners b
on
a.cardid = b.cardid
You can use something like this:
See SQL Fiddle with Demo
Result:
Based on your edit, here is an attempt that returns the correct result however I am not sure if it will work with the larger dataset that you have:
See SQL Fiddle with Demo
Result: