Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Introduction
The very basics
Infinite looping
Processing graphs with recursive CTE
Summary
34. Exercise 2

Instruction

Alright. It's time for an example with a tree.

Exercise

Take a look at the table folder. Each folder has an id, a name and the id of a parent, which is the folder from which we can access the given folder.

Show four columns: id, name, parent_id and path. The last column should contain the path to the folder, starting with '/', followed by all folder names separated by '/'. At the end of the path, there should be the name of the given folder and a slash ('/'). An example for folder B which is in root folder A would be: /A/B/.

The root folder has NULL parent_id. For that folder, the path should be: /.