sqlite - Recursive Query CTE in SQL Lite -


i have following table structure. (i new sql lite)

create table relations  ( code int, parentcode int , fname text ) go insert relations values(1,null,'a'); insert relations values(2,null,'b'); insert relations values(3,2,'c'); insert relations values(4,3,'d'); 

i want initial parent of code =4 : i.e. values 2 null b

i not able figure out how write recursive query in sqllite. in advance..

was version issue.. query not working & getting syntax error. upgraded 3.7.17 3.8.7.4 version & worked..

with recursive   works(code,parent) (    select code,parentcode relations a.code=4     union     select relations.code, relations.parentcode relations , works      relations.code=works.parent   ) select * works parent null 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -