try this select statement ....

select id from table1 where id in (select a.id from table2 a
group by a.id having count(*) > 1);

Veera

Ravindra Basavaraja wrote:

> Hi,
>
> I am having problem in writing a query.May be this is a elementary Q but I
> need help
>
> Table 1:
> id      value
> --      ------
> a       3
> b       3
> c       3
> d       3
> e       3
> id is primary key
>
> Table 2:
> a_id    value
> -----   ------
> a       3
> b       3
> c       3
> d       3
> e       3
> a       0
> b       4
> a       3
> b       3
> c       2
> c       3
> a_id is foreign key referencing Table1(id)
>
> I want to display the records that are being repeated comparing with the id
> in table 1
> where value=3 in the second table i.e
> the o/p should be id 'd' is not being repeated
>
> id      value
> --      ------
> a       3
> b       3
> c       3
>
> How do i write the query
>
> Thanks
>
> ravindra
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Ravindra Basavaraja
>   INET: [EMAIL PROTECTED]
>
> Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
> San Diego, California        -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Veera Prasad
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to