Re: Odd query

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Joshua Adam Ginsberg <rainman(at)owlnet(dot)rice(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Odd query
Date: 2001-09-26 01:41:20
Message-ID: 20010926114120.A25048@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 25, 2001 at 08:30:37PM -0500, Joshua Adam Ginsberg wrote:
> Let's say I have a table :
>
> create table people (
> person_id integer not null primary key,
> firstnames varchar(50),
> lastname varchar(50)
> );
>
> and another
>
> create table partners (
> first_person integer not null references people(person_id),
> second_person integer not null reference people(person_id)
> );

> first_firstnames | first_lastname | second_firstnames | second_lastname
> -----------------+----------------+-------------------+----------------
> Prince Of | Darkness | William Henry | Gates
> Prince Of | Darkness | Steve | Case

select a.firstnames as first_firstnames, a.lastname as first_lastname,
b.firstnames as second_firstnames, b.lastname as second_lastname
from people a, people b, partners
where a.person_id = partners.first_person
and b.person_id = partners.second_person;

HTH,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> Magnetism, electricity and motion are like a three-for-two special offer:
> if you have two of them, the third one comes free.

In response to

  • Odd query at 2001-09-26 01:30:37 from Joshua Adam Ginsberg

Browse pgsql-general by date

  From Date Subject
Next Message Marshall Spight 2001-09-26 02:04:52 Can't dump a database
Previous Message Joshua Adam Ginsberg 2001-09-26 01:30:37 Odd query