On Jul 9, 2008, at 3:23 PM, Shawn Wilsher wrote:
> Hey all,
>
> Quick (and hopefully simple) question regarding subselects in a where
> clause. Does sqlite cache the values of a subselect so it doesn't
> have to run the query each time it evaluates a row?
>
> Example:
> SELECT *
> FROM foo
> WHERE id NOT IN (SELECT id FROM bar)
Yes it does.
Assuming it is possible. If the subquery depends on the outer query
that is not possible. Example:
SELECT * FROM foo WHERE id NOT IN (SELECT id FROM bar WHERE
x>foo.y)
So in your original query, the subquery runs once and the results are
cached. In the second query, the subquery runs once for each row in
the result set.
D. Richard Hipp
[EMAIL PROTECTED]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users