my SQLite database is kinda like this:
| startn | rel | endn |
|---|---|---|
| immunodeficiencies | includes | B-cell deficiencies |
| B-cell deficiencies | includes | Bruton agammaglobulinemia |
| immunodeficiencies | includes | T-cell deficiencies |
| T-cell deficiencies | includes | DiGeorge syndrome |
There's a lot more values, but that's the gist.
I'm trying to make a recursive query that gets all the terminal child nodes of immunodeficiencies. Ie, for this example I'd like Bruton agammaglobulinemia, DiGeorge syndrome
Based on another answer, here's what I have so far, but it's not working:
with recursive tc( i ) as ( select endn from dx_graph where startn = 'immunodeficiencies' and rel = 'includes' union endn from dx_graph, tc where startn = tc.i and rel = 'includes' ) select * from tc; https://stackoverflow.com/questions/65756502/recursive-sqlite-query January 17, 2021 at 09:38AM
没有评论:
发表评论