On Sun, 22 Mar 2015 19:04:50 -0400
Stephen Chrzanowski <pontiac76 at gmail.com> wrote:

> What I'm gathering from Igor and Ryan is that even though the subquery
> looks to be a self contained entity, it actually isn't?

Right, it actually isn't.  All the names mentioned in the outer query
are in scope for the inner one

$ sqlite3 :memory: <<EOF
create table T (t int);
insert into T values (1);
select * from T where t in (select t);
EOF

t         
----------
1         

The query establishes a lexical scope.  They're visible within
subqueries. It's similar to how in C global variables are visible within
functions.  

--jkl


> On Sun, Mar 22, 2015 at 6:27 PM, Igor Tandetnik <igor at tandetnik.org>
> wrote:
> 
> > On 3/22/2015 11:50 AM, Bart Smissaert wrote:
> >
> >> Still, in this particular case it seems odd as there is only one
> >> column and
> >> one table in the sub-select.
> >>
> >
> > I'm not sure I understand what significance you ascribe to this
> > fact. Why again should the number of columns or tables in subselect
> > matter?
> >
> > --
> > Igor Tandetnik
> >
> > _______________________________________________
> > sqlite-users mailing list
> > sqlite-users at mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to