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

Re: BUG #5898: Nested "in" clauses hide bad column names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Scott Dunbar" <scott(at)xigole(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5898: Nested "in" clauses hide bad column names
Date: 2011-02-22 17:45:03
Message-ID: 3314.1298396703@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
"Scott Dunbar" <scott(at)xigole(dot)com> writes:
> I have a nested in clause like:

> select respondent_id from respondent where respondent_id in (select
> respondent_id from chat_session where project_id in (select project_id from
> project where company_id = 4));

> However, in this example, there is no column named respondent_id in the
> chat_session table.

Probably there is one in respondent, though?  This behavior is not a bug
--- what you have there is an outer reference, and it is working exactly
as specified by the SQL standard.  Sub-selects would be a whole lot less
useful if they couldn't refer to variables of the outer query.

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Scott DunbarDate: 2011-02-22 18:07:39
Subject: Re: BUG #5898: Nested "in" clauses hide bad column names
Previous:From: Scott DunbarDate: 2011-02-22 17:26:25
Subject: BUG #5898: Nested "in" clauses hide bad column names

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