X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7B86CD1C4EE for ; Mon, 28 Jul 2003 16:36:41 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 01806-05 for ; Mon, 28 Jul 2003 13:35:44 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 5BDEAD1C4EC for ; Mon, 28 Jul 2003 13:36:39 -0300 (ADT) Received: (qmail 25842 invoked by uid 500); 28 Jul 2003 16:41:29 -0000 Date: Mon, 28 Jul 2003 11:41:29 -0500 From: Bruno Wolff III To: oheinz@stud.fbi.fh-darmstadt.de Cc: pgsql-sql@postgresql.org Subject: Re: Problem using Subselect results Message-ID: <20030728164129.GA25693@wolff.to> Mail-Followup-To: oheinz@stud.fbi.fh-darmstadt.de, pgsql-sql@postgresql.org References: <1058964708.3f1e84e407a8d@stud.fbi.fh-darmstadt.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1058964708.3f1e84e407a8d@stud.fbi.fh-darmstadt.de> User-Agent: Mutt/1.5.4i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/413 X-Sequence-Number: 14527 On Wed, Jul 23, 2003 at 14:51:48 +0200, oheinz@stud.fbi.fh-darmstadt.de wrote: > I want to use the result of a subselect as condition of another one. The two selects you use ar both from items at the same level and hence can't reference one another. In your example below you could just use a join. > CREATE VIEW my_view AS SELECT b,c > (SELECT a, b FROM table2 WHERE b=1) my_ab, > (SELECT c FROM table3, my_ab WHERE table3.a=my_ab.a) my_c; Something like: CREATE VIEW my_view AS SELECT table2.b, table3.c from table2, table3 where table2.b = 1 and table2.a = table3.a;