Skip site navigation (1) Skip section navigation (2)

Re: Subqueries

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: <ptufenkji(at)usj(dot)edu(dot)lb>
Cc: "'Helio Campos Mello de Andrade'" <helio(dot)campos(at)gmail(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Subqueries
Date: 2008-10-31 10:58:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
"Pascal Tufenkji" <ptufenkji(at)usj(dot)edu(dot)lb> writes:

> I understand the fact that "the inner query is executed before the outer
> query and the inner query doesn't even know about the outer query."
> But why the following query can be executed, although the inner query is
> using the outer query.
> Aren't we here using the same concept ?

It's not that inner queries can't refer to outer queries. When they do it's
called a "correlated subquery" and it has to be executed once for every row of
the outer query.

It's that queries on one side of a join can't refer to tables on the other
side of the join.

  Gregory Stark
  Ask me about EnterpriseDB's On-Demand Production Tuning

In response to

pgsql-sql by date

Next:From: Bryce NesbittDate: 2008-11-02 17:51:21
Subject: Seq scan on join, not on subselect? analyze this
Previous:From: Pascal TufenkjiDate: 2008-10-31 09:26:12
Subject: Re: Subqueries

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group