X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 75453D1D52E for ; Wed, 11 Feb 2004 21:24:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 10790-05 for ; Wed, 11 Feb 2004 17:23:50 -0400 (AST) Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) by svr1.postgresql.org (Postfix) with ESMTP id 1AAB6D1D17D for ; Wed, 11 Feb 2004 17:23:49 -0400 (AST) Received: from [192.168.0.1] (dsl-082-082-103-145.arcor-ip.net [82.82.103.145]) (authenticated) by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id i1BLNPA15623; Wed, 11 Feb 2004 22:23:26 +0100 Subject: Re: Multiple outer join on same table From: Markus Bertheau To: Marco Lazzeri Cc: pgsql-sql@postgresql.org In-Reply-To: <1076350332.31616.45.camel@macbeth.intranet.noze.it> References: <1076350332.31616.45.camel@macbeth.intranet.noze.it> Content-Type: text/plain; charset=UTF-8 Message-Id: <1076534606.1984.8.camel@yarrow.bertheau.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.5.3 (1.5.3-1) Date: Wed, 11 Feb 2004 22:23:26 +0100 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/104 X-Sequence-Number: 16795 On =D0=9F=D0=BD=D0=B4, 2004-02-09 at 19:12 +0100, Marco Lazzeri wrote: > Hi! > I'm searching a better (quicker) way to retrieve data as I used to do > using the following query... >=20 > =3D=3D > SELECT > main.codice, > other.value AS value_one, > other.value AS value_two > FROM main LEFT OUTER JOIN other ON main.id =3D > other.id_main > LEFT OUTER JOIN other AS other2 ON main.id =3D > other2.id_main > WHERE > other.type =3D 'type_one' > AND other2.type =3D 'type_two'; > =3D=3D You can alias a table to join it to itself. I'm not sure whether that answers your question. SELECT t1.field FROM table AS t1 JOIN table as t2 on (cond) --=20 Markus Bertheau