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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Query Syntax Question...

Re: Query Syntax Question...

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sun, 1 Oct 2000 22:07:24 +0200
Message-ID: <970466389.26039.0.pluto.d4ee154e@news.demon.nl>

No problem at all:

select committee_id

       , treasurer_id
      ,  tn.fname||' '||tn.lname treasurer_name
      , secretary_id
      , sn.fname||' '||sn.lname secretary_name
from committee
     , employee tn
     , employee sn

where tn.employee_id = treasurer_id
  and sn.employee_id = secretary_id

Hth,

Sybrand Bakker, Oracle DBA

"Kent P. Iler" <kent_at_iler.NOSPAM.com> wrote in message news:NGJB5.2201$9O3.292683_at_typhoon.mw.mediaone.net...
> Hi,
>
> How do I (or can I?) write a query to pull back the ID's and names in the
> following schema?
>
> committee_table:
> Committee_ID int,
> Treasurer_ID int,
> Secretary_ID int
> --------------------
>
> Employee_table:
> Employee_ID int,
> FNAME varchar,
> LNAME varchar
>
> The problem is all employees are in one table. I want to pull back the
 name
> of each employee that matches the committee ID, so the output I would like
> to see is:
>
> Committee_ID Treasurer_ID Treasurer_Name Secretary_ID Secretary_Name
>
> So each row of the committee_table would need to reference 2 rows in the
> Employee table, 1 for the treasurer and 1 for the secretary.
>
> Obviously a join would work if I only had 1 name to reference, but I'm
> having trouble with the 2 names. I don't know if there is a more complex
> join that could work here.
>
> Thanks.
>
> -- Kent Iler
> ----------------------------------------------------------------------
> kent_at_iler.NOSPAM.com
> Please CC: all replies via e-mail
> Remove .NOSPAM from e-mail address
>
>
>
Received on Sun Oct 01 2000 - 15:07:24 CDT

Original text of this message

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