>>> (2) What about cycles? How does one deal with them?

>> With cycles, you probably want to use UNION instead of UNION ALL to
>> stop at duplicate records.

>Hmmm... not quite sure how this would play out in practice... how would the
>recursion known when to stop?

>Say,  given a circular hierarchy such as A-> B -> A.... when does the
>recursion stop?

UNION ALL means union all rows, even duplicates.
UNION means union all DISTINCT rows.

So it is not so much a matter of stopping as of not adding (hence recursing) 
from row A once it has already been seen.

Read the docs.  It explains how recursive CTEs are computed and how UNION ALL 
vs UNION work in CTEs.




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

Reply via email to