From: Christoph Haller <ch@rodos.fzk.de>
To: oheinz@stud.fbi.fh-darmstadt.de
To: pgsql-sql@postgresql.org
Subject: Re: Problem using Subselect results
Date: Thu, 24 Jul 2003 14:11:15 +0200
Message-ID: <3F1FCCE2.47ACF401@rodos.fzk.de> (raw)
> I want to use the result of a subselect as condition in another one.
>
> table1: a,b
> table2: a,c
>
> CREATE VIEW my_view AS SELECT b,c
> (SELECT a, b FROM table1 WHERE b=3D1) my_ab,
> (SELECT c FROM table2, my_ab WHERE table3.a=3Dmy_ab.a) my_c;
>
> this is just an example - i know i could cross join this one, but i
need =
> to=20
> refer to the results of several subselects in several other.
>
>
> does return "relation my_ab unknown". it is not just a problem of
executi=
> on=20
> order - if i turn it the other way round it's still the same.
>
> Am I just trying to do something really stupid? And what for is the
(nece=
> ssary)=20
> AS statement for subselects, if it's not possible to access their
results=
> by=20
> that name?
>
> And as I need the result of a subselect in several other subselects
it's=
> not=20
> possible to transform them into a cascade of sub, subsub,
subsubsub.... s=
> elects.
> Any ideas?=20
>
Does this match your intentions:
CREATE VIEW my_view AS SELECT b,c FROM
(SELECT b,c FROM table2, (SELECT a, b FROM table1 WHERE b=3D1) my_ab
WHERE table3.a=3Dmy_ab.a) my_c;
I assume the reference table3.a is a typo.
Regards, Christoph
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: ch@rodos.fzk.de, oheinz@stud.fbi.fh-darmstadt.de
Subject: Re: Problem using Subselect results
In-Reply-To: <3F1FCCE2.47ACF401@rodos.fzk.de>
* 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