I see, thank you for pointing out.

I wanted to use it on table with conditional relations with 3 different child 
tables.
Though I could use a trick and fit data selection into one query, efficiently.
Alas I am forced to stick to 2 queries.

Thank you!

8 February 2016, 12:08:26, by "Clemens Ladisch" <clemens at ladisch.de>:

>   Paul wrote:
> > I am curious what is a particular reason that aliased columns in a query 
> > not visible to sub-queries?
> 
> Because the SQL standard says so.
> 
> > Of course it is possible to duplicate expression in sub-query ...
> > But this would not be as efficient as to access result of already evaluated 
> > expression.
> 
> An alias refers not to an expression's value but to the expression
> itself, so it would not be any more efficient.  (SQLite's optimizer
> typically is not smart enough to detect and remove the duplication.)
> 
> 
> As a workaround, you have to move the expression into a subquery in
> the FROM clause:
> 
> SELECT super_id,
>        (SELECT qux FROM baz WHERE id = super_id)
> FROM (SELECT id as super_id FROM foo);
> 
> 
> Regards,
> Clemens
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Reply via email to