Re: A way to refer to the "outer" query implicitly?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A way to refer to the "outer" query implicitly?
Date: 2004-03-20 04:18:12
Message-ID: 3900.1079756292@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greg Stark <gsstark(at)mit(dot)edu> writes:
> However one of the constraint clauses is
> exists (select 1 from othertable where x = outertable.x)
> This works fine, but requires that the caller know that the table being
> queried will be "outertable". Is there any way in a subquery used like this to
> implicitly reference fields from the outer query?

If the column name does not belong to any of the tables of the inner
query then it will automatically be sought in the outer query. If you
are dealing with a name that does appear at both levels, you're outta
luck ... got to qualify it.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-03-20 05:39:54 Re: Index selection (and partial index) for BYTEA field
Previous Message Jan Wieck 2004-03-20 03:13:47 Re: does this look more like a possible bug or more like