Re: Problem using Subselect results - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: Problem using Subselect results
Date
Msg-id 20030728164129.GA25693@wolff.to
Whole thread Raw
In response to Problem using Subselect results  (oheinz@stud.fbi.fh-darmstadt.de)
List pgsql-sql
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;


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Using a compound primary key
Next
From: Tom Lane
Date:
Subject: Re: Very strange 'now' behaviour in nested triggers.