Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
SQL hierarchical query. branch of responses.
with recursive messages as ( select 1 as id, 1 as uid, 'a' as m, null as to_id union all select 2 as id, 1 as uid, 'b' as m, 1 as to_id union all select 3 as id, 1 as uid, 'c' as m, null as to_id union all select 4 as id, 1 as uid, 'd' as m, 1 as to_id union all select 5 as id, 1 as uid, 'e' as m, 2 as to_id union all select 6 as id, 1 as uid, 'f' as m, 1 as to_id union all select 7 as id, 1 as uid, 'g' as m, 2 as to_id ), q0 as ( select * from messages where m = 'a' ), q1(tid, msg, lvl) as ( select id, m, 0 from q0 union all select id, m, lvl + 1 from messages inner join q1 on to_id = tid ) select * from q1
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
FlujoPadre
Query for matching substring from text field in DB
LeetCode 262
Recursive inefficiency
Final 2
75 95
Replace key of json
project 1
Assignment 1(SET A)
Joins and Case
Please log in to post a comment.