Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: SQL Query

Re: SQL Query

From: fumi <fumi_at_tpts5.seed.net.tw>
Date: 4 Aug 1999 16:38:26 GMT
Message-ID: <7o9qa2$pna$1@news.seed.net.tw>

<owais_anjum_at_my-deja.com> wrote in message news:7npo36$lqq$1_at_nnrp1.deja.com...
> 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.

select item_id
  from test
  where related_item in ('111', '222', '333')   group by item_id
  having count(distinct related_item)=3; Received on Wed Aug 04 1999 - 11:38:26 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US