How to make recursive query in SQLite?

前端 未结 4 1732

if my data structure is like this

parentA
-------parentAA
--------------parentAAA
---------------------childA

if i can get \"childA.name\" . h

4条回答
  •  没有蜡笔的小新
    2021-02-11 06:28

    I have a table called project with a column named rates. The rates column is a string that holds a JSON array. To split this string into rows that I can use in an IN statement to get rows from the related table, I use this for the IN part

    WITH
     split(s, p) AS (
     SELECT substr(printf("%s%s", ss, ","), instr(ss, ",")+1), trim(substr(ss, 0, instr(ss, ","))) from ( select replace(replace(rates,"[",""), "]","") ss from project where rowid = 1)
     UNION ALL
     SELECT substr(s, instr(s, ",")+1), trim(substr(s, 0, instr(s, ","))) FROM split
     where p!=""
     )
     select p from split where p!=""
    

提交回复
热议问题