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

Home -> Community -> Usenet -> comp.databases.theory -> Re: normalization - two linked fields in one table

Re: normalization - two linked fields in one table

From: Theo Peterbroers <peterbroers_at_floron.leidenuniv.nl>
Date: 11 Nov 2002 05:00:06 -0800
Message-ID: <39bb2c10.0211110500.2b73b7ff@posting.google.com>


"Trooper" <andrew_zx5_at_NOSPAMyahoo.com> wrote in message news:<JhIz9.796567$Ag2.27051080_at_news2.calgary.shaw.ca>...
> I'm setting up a small web based program to help manage "Tasks" between
> family members. Kind of like Bugzilla, but on a way smaller scale.
> My problem is that a "Task" has two fields in it that relate to the same
> table:
>
> Task User
> ==== ====
> TaskID UserID
> assigned_to name
> poster_id
>
> assigned_to and poster_id are linked to the UserID.
<...>
> can't figure out how
> to pull a name from the User table for each of the two fields in the Task
> table.
>

You need to join the user table twice, once for assignee, then for poster:

SELECT t.TaskID, a.name as Assignee, p.name as Poster FROM (Task as t INNER JOIN User as a ON t.assigned_to=a.UserID)

                INNER JOIN User as p ON t.poster_id=a.UserID
Received on Mon Nov 11 2002 - 07:00:06 CST

Original text of this message

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