What is happening here?
I got two tables, test1 and test2:
create table test1 (id1 int4 primary key); create table test2 (id2 int4 primary key);
Columns from outer select are visible in sub-select.
select
Your query is equivalent to:
select * from test1 where test1.id1 in (select test1.id1 from test2);