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: Michael Bialik <michael_bialik_at_my-deja.com>
Date: Sun, 01 Oct 2000 20:45:45 GMT
Message-ID: <8r87po$77m$1@nnrp1.deja.com>

Hi.

 Try

 SELECT
  cmt.Committee_ID,
  cmt.Treasurer_ID,
  tr.FNAME || ' ' || tr.LNAME treasurer_name,   cmt.Secretary_ID,
  sec.FNAME || ' ' || sec.LNAME secretary_name  FROM
  committee_table cmt,
  employee_table tr,
  employee_table sec
 WHERE
  cmt.Treasurer_ID = tr.Employee_ID and
  cmt.Secretary_ID = sec.Employee_ID ;

 HTH. Michael
In article <NGJB5.2201$9O3.292683_at_typhoon.mw.mediaone.net>,   "Kent P. Iler" <kent_at_iler.NOSPAM.com> wrote:
> 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
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sun Oct 01 2000 - 15:45:45 CDT

Original text of this message

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