Re: Subselect with incorrect column not a syntax error?

From: Jack Christensen <jackc(at)hylesanderson(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Subselect with incorrect column not a syntax error?
Date: 2012-04-13 17:59:20
Message-ID: 4F886978.4080508@hylesanderson.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 4/13/2012 11:39 AM, Mike Blackwell wrote:
> Could someone please explain to me why the following select does not
> result in a syntax error? (9.0.3)
>
> begin;
>
> create table x( c1 integer , c2 integer);
> create table y( c3 integer, c4 integer);
>
> select * from x where c2 in ( select c2 from y where c4 = 2 );
>
>
> rollback;
>
> Mike
>
Your subquery is correlated with the outer query. So the c2 in the
subquery is referring to table x.

--
Jack Christensen
jackc(at)hylesanderson(dot)edu

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christian Andersen 2012-04-13 18:03:44 Problems with restoring data (using pg_restore)
Previous Message Christian Andersen 2012-04-13 17:47:58 Problems with restoring data (using pg_restore)