I still don't fully understand how this works but I've gotten to my end goal and am massively grateful for your help getting there, thank you!
@kssabin786
2 жыл бұрын
Recursive CTE, we can use the 1st cte results as a input to next level, so upto some criteria we can use this method like tree structure - node, leaf..
@AkysChannel
Жыл бұрын
For people struggling with never-returning query: try to make the condition in the "non-recursive term" part of the query to be `"your_column_name" IS NULL` and not any other condition.
@guilhermealvessilveira8938
2 жыл бұрын
Excellent explanation, thank you.
@rafiktaamma9959
2 жыл бұрын
thank you my brother . simple and usefull
@marceli-wac
3 жыл бұрын
NIce one, thanks for sharing!
@cutiiieekudi6817
8 ай бұрын
0:41 DH
@mkroven
3 жыл бұрын
Great content. Thank you.. I used closure table for a ecommerce product categories to query ancestor category and descandants. Your tree solution seems better.
@Rowadz
3 жыл бұрын
Thanks for sharing, I didn't know about closure tables I'll read about them
@CarpetEraser
2 жыл бұрын
this is great, thx!
@poojathakur5547
Жыл бұрын
Hi - i have return the cte but i want to used it with the crosstab function to transpose the values from rows to columns , but i am getting an error
@syakhiskk
10 ай бұрын
❤
@lefteriskontomarkos9097
2 жыл бұрын
Excellent explanation!!! I was revisiting a recursive CTE query of mine that was throwing an error, and your video greatly helped me understand in depth the concept
@Rowadz
Жыл бұрын
Glad it helped!
@rembautimes8808
9 ай бұрын
Thanks this is an excellent tutorial .Joined as sub
@tendimuchenje7984
2 жыл бұрын
this is great content. I am trying to write my own recursive query, but I am running into issues. Is there anyway to reach your for a brief consultation?
@santoshadhikari9933
2 жыл бұрын
how do you get unique only element in single column of that whole hierarchy
@Rowadz
2 жыл бұрын
I'm not sure I understand completely but try doing that after the recersive CTE. The result from the CTE is just like a table, you can do anything on it.
@ftnsco
2 жыл бұрын
Why not use LTREE?
@Rowadz
2 жыл бұрын
Because I've never heard of it XD but it looks really interesting
@carolinarojano7298
3 жыл бұрын
Hello, what can i do if i'm working with something similar like, getting all the prerequisites for a course, which i did like this WITH RECURSIVE db_req AS( SELECT course_id, req_id FROM pre_requisitos WHERE course_id = 2 UNION SELECT p.course_id, p.req_id FROM pre_requisitos p INNER JOIN db_req as d ON d.req_id = p.course_id ) SELECT req_id FROM db_req; But now i need all the prerequisites of all courses, i'm guessing i have to iterate over all the courses but don't know how exactly
@Rowadz
3 жыл бұрын
not sure If I have a soultion for u, but can adding the course root id in each row help? WITH RECURSIVE db_req AS ( SELECT course_id, req_id, course_id FROM pre_requisitos UNION SELECT p.course_id, p.req_id, db_req.course_id, FROM pre_requisitos p INNER JOIN db_req as d ON d.req_id = p.course_id ) SELECT req_id FROM db_req;
@Rowadz
3 жыл бұрын
maybe also getting the level of each node with the path of the privouse courses ids (requisitos) could help like this WITH RECURSIVE db_req AS( SELECT course_id, req_id, course_id 0 as emp_level, e1.id::VARCHAR as c_id FROM pre_requisitos UNION SELECT p.course_id, p.req_id, db_req.course_id, db_req.nesting_level+1, db_req.c_id::VARCHAR || ',' || p.id::VARCHAR FROM pre_requisitos p INNER JOIN db_req as d ON d.req_id = p.course_id ) SELECT req_id FROM db_req;
Пікірлер: 23