Marcel Strittmatter <[email protected]>
wrote:
> I implemented a custom function that returns a comma separated list of
> primary keys as a string by making recursive queries. This works well
> if I don't use subqueries. But I like to use subqueries like this
>
> SELECT * FROM users WHERE id IN (SELECT parents('relations', 3));
>
> Is it possible to implement a custom function where the result can be
> used in a subquery like above?

No, not really. SQLite doesn't have table-valued functions. SQLite does 
have the concept of a virtual table:

http://www.sqlite.org/c3ref/module.html

Maybe you could do something like what you want with those. I don't know 
enough about them to comment further.


With the function as written, you can do something like this:

SELECT * FROM users WHERE
','||parents('relations', 3)||',' LIKE '%,'||id||',%';

I don't really recommend this monstrosity, just mention it for 
completeness.

Igor Tandetnik 



_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to