Re: Join question

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: "Williams, Travis L, NPONS" <tlw(at)att(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Join question
Date: 2003-05-30 02:25:16
Message-ID: 20030529192403.W72395-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 29 May 2003, Williams, Travis L, NPONS wrote:

> I have a table that is set up like this
>
> table A:
> First_name,Last_name,login
>
> I have another table that is set up like this
>
> table B:
> date,date,person1,person2,person3
>
> where the person1,2,3 is the login name from the first table.
>
> I need to get the first_name and last_name of all 3 persons using one
> select (well I don't have to do it in one.. but I thought it would be
> cleaner).. I can do one person using a join select like this:
>
> select A.First_name,A.Last_name from A,B where B.person1 = A.login
>
> I tried adding an or statement like "or B.person2 = A.login" but that
> returns 2 entrys for each row.. where I'm trying to get all the
> information back in one.

I think it'd be something like:
select a1.first_name, a1.last_name, a2.first_name, a2.last_name,
a3.first_name, a3.last_name from
A a1, A a2, A a3, B where
B.person1=a1.login and B.person2=a2.login and B.person3==a3.login;

In response to

  • Join question at 2003-05-30 00:20:35 from Williams, Travis L, NPONS

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-05-30 02:29:13 Re: Join question
Previous Message elein 2003-05-30 02:22:04 to_char (was Re: fomatting an interval)