X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B352BD8020 for ; Sun, 11 Sep 2005 20:33:40 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86923-01 for ; Sun, 11 Sep 2005 23:33:37 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 545F0D774E for ; Sun, 11 Sep 2005 20:33:36 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j8BNXbr3042208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 11 Sep 2005 17:33:40 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j8BNXbui055396; Sun, 11 Sep 2005 17:33:37 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j8BNXbVI055395; Sun, 11 Sep 2005 17:33:37 -0600 (MDT) (envelope-from mfuhr) Date: Sun, 11 Sep 2005 17:33:37 -0600 From: Michael Fuhr To: Ferindo Middleton Jr Cc: pgsql-sql@postgresql.org Subject: Re: showing multiple reference details from single query Message-ID: <20050911233337.GA54749@winnie.fuhr.org> References: <4324B1C0.7060407@verizon.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4324B1C0.7060407@verizon.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200509/122 X-Sequence-Number: 22669 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