On 18 Dec 2016, at 6:41pm, Keith Maxwell <keith.maxw...@gmail.com> wrote:

> Thanks again, maybe I didn't ask the question in the best way:  why
> with the query below do I get "Error: no such column: z"?
> 
> SELECT (SELECT y FROM t1 ORDER BY abs(x - z) LIMIT 1) FROM t2;

Because the inner SELECT does not have access to the details from the outer 
SELECT.  It does not know what 'z' is.  None of the tables in the inner SELECT 
have a column called 'z'.

This works:

SELECT y FROM t1 ORDER BY abs(x - (SELECT z FROM t2)) LIMIT 1;

though I do not know if it does what you want it to do.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to