pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: oheinz@stud.fbi.fh-darmstadt.de
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem using Subselect results
Date: Mon, 28 Jul 2003 11:41:29 -0500
Message-ID: <20030728164129.GA25693@wolff.to> (raw)
In-Reply-To: <1058964708.3f1e84e407a8d@stud.fbi.fh-darmstadt.de>
References: <1058964708.3f1e84e407a8d@stud.fbi.fh-darmstadt.de>

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;



view thread (15+ messages)  latest in thread

Message-ID: <20030728164129.GA25693@wolff.to>
Permalink:  ../20030728164129.GA25693@wolff.to/
Also on:    postgresql.org/message-id/20030728164129.GA25693@wolff.to

 · 

reply

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: bruno@wolff.to, oheinz@stud.fbi.fh-darmstadt.de
  Subject: Re: Problem using Subselect results
  In-Reply-To: <20030728164129.GA25693@wolff.to>

* 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