Re: [sqlite] Aliases in subqueries?

2010-04-02 Thread Igor Tandetnik
Fredrik Karlsson wrote:
 Sorry for asking this SQL question, but I just have to make sure:
 
 -  Aliases in subqueries - are the always, local to the scope of the subquery?
 
 
 That is, if I have this query (this example makes _no_ sense, I know.
 Just an illustration.):
 
 select target.* from
 (
select target.* from
  (select m.id, n. name from mytable m, myothertable, n where
 m.id = n.id) target,
  (select m.id, n. name from mytable m, myothertable, n where
 m.id = n.id) comp1,
where  target.id = comp1.id
 ) target,
 mytable t
 where  t.id = target.id;
 
 will the aliases at the different levels be safe inside of their
 subquery so that e.g. target in the outer query will be intact once
 the subquery has been evaluated?

Yes. Apart from a misplaced comma here and there, this statement should work.
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Aliases in subqueries?

2010-04-02 Thread Fredrik Karlsson
On Fri, Apr 2, 2010 at 1:59 PM, Igor Tandetnik itandet...@mvps.org wrote:
 Fredrik Karlsson wrote:
 Sorry for asking this SQL question, but I just have to make sure:

 -  Aliases in subqueries - are the always, local to the scope of the 
 subquery?


 That is, if I have this query (this example makes _no_ sense, I know.
 Just an illustration.):

 select target.* from
 (
    select target.* from
          (select m.id, n. name from mytable m, myothertable, n where
 m.id = n.id) target,
          (select m.id, n. name from mytable m, myothertable, n where
 m.id = n.id) comp1,
    where  target.id = comp1.id
 ) target,
 mytable t
 where  t.id = target.id;

 will the aliases at the different levels be safe inside of their
 subquery so that e.g. target in the outer query will be intact once
 the subquery has been evaluated?

 Yes. Apart from a misplaced comma here and there, this statement should work.
 --
 Igor Tandetnik

 ___
 sqlite-users mailing list
 sqlite-users@sqlite.org
 http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Hi,

Excellent! Thank you for having a look at this.

/Fredrik

-- 
Life is like a trumpet - if you don't put anything into it, you don't
get anything out of it.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users