Re: SQL Query

From: Chris Colclough <chris.colclough_at_jhuapl.edu.nospam>
Date: Fri, 30 Jul 1999 08:03:22 -0400
Message-ID: <37A1948A.DF23537C_at_jhuapl.edu.nospam>


How about:

select item_id
from tt
group by item_id
having count(*) =
(select count(*)
from tt t2
where related_item_id in (111,222,333)
and t2.item_id = tt.item_id)
/

owais_anjum_at_my-deja.com wrote:

> Hello
>
> I have a table with the following structure and data:
>
> ITEM_ID RELATED_ITEM
> ==========================
> aaa 111
> aaa 222
> aaa 333
> bbb 111
> bbb 777
> xxx 909
>
> The query I want should return all the item_id's against a given list of
> related_items. e.g. I want an item_id which has all of the listed
> related_items ('111',222','333').
>
> I thought ALL was meant for such scenarios...but I've not had any
> success with it so far.
>
> Waiting for opinions
> Owais
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Fri Jul 30 1999 - 14:03:22 CEST

Original text of this message