From: Michael Fuhr <mike@fuhr.org>
To: Ferindo Middleton Jr <fmiddleton@verizon.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: showing multiple reference details from single query
Date: Sun, 11 Sep 2005 17:33:37 -0600
Message-ID: <20050911233337.GA54749@winnie.fuhr.org> (raw)
In-Reply-To: <4324B1C0.7060407@verizon.net>
References: <4324B1C0.7060407@verizon.net>
On Sun, Sep 11, 2005 at 06:37:52PM -0400, Ferindo Middleton Jr wrote:
> table_one has the following columns:
> id (SERIAL), column_one (INTEGER REFERENCES table_two(id)), column_two
> (INTEGER REFERENCES table_two(id))
>
> table_two has the following columns:
> id (SERIAL), more_detailed_info (TEXT)
>
> How can I write a single query which will can uniquely identify in the
> result the separated values of the more_detailed_info field of
> table_two?
I think you're looking for something like this:
SELECT t1.id,
t1.column_one, t2a.more_detailed_info,
t1.column_two, t2b.more_detailed_info
FROM table_one AS t1
JOIN table_two AS t2a ON t2a.id = t1.column_one
JOIN table_two AS t2b ON t2b.id = t1.column_two;
--
Michael Fuhr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mike@fuhr.org, fmiddleton@verizon.net
Subject: Re: showing multiple reference details from single query
In-Reply-To: <20050911233337.GA54749@winnie.fuhr.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox