adam.c.scott@gmail.com writes:
> create table administrators (pk integer, login_pk integer);
> create table logins (pk integer, name character varying(64));
> select * from administrators where login_pk in (select login_pk from
> logins);
> It should say something along the lines of:
> ERROR: column "login_pk" does not exist
Unfortunately not, because that's a perfectly SQL-standard outer reference
in a subquery.
Many people have adopted the habit of always table-qualifying column
references in subqueries to save themselves from this type of mistake.
That is, if you'd done something like
select * from administrators a where a.login_pk in
(select l.login_pk from logins l);
then you would indeed have gotten a complaint about l.login_pk not
being found in the expected table.
regards, tom lane