Re: Subselects - recursion problem - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: Subselects - recursion problem
Date
Msg-id 200505301142.57483.peter_e@gmx.net
Whole thread Raw
In response to Subselects - recursion problem  (Philip Rhoades <phil@chu.com.au>)
List pgsql-general
Philip Rhoades wrote:
> The following script works (I have confirmed it by doing two separate
> views and doing a select on them) - but I don't understand why there
> isn't a recursion problem with c1.policy and c2.policy - is there
> some sort of trick happening?

The subquery is evaluated for each row of the outer query.  The
references to c1 are for each evaluation replaced by the current values
of the outer query.  For the purpose of the subquery, they behave like
constants.

Internally, the query might actually be transformed into a join of c1
and c2.  Maybe that helps you grasp it.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

pgsql-general by date:

Previous
From: Philip Rhoades
Date:
Subject: Subselects - recursion problem
Next
From: Martijn van Oosterhout
Date:
Subject: Re: Subselects - recursion problem