Created
October 1, 2013 19:45
-
-
Save ambantis/6784006 to your computer and use it in GitHub Desktop.
a Postgres view that recursively finds all children, grand-children, great-grand-children, etc. of a Google Drive folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE VIEW scion_view AS | |
WITH RECURSIVE scions(id, scion) AS ( | |
SELECT c.id, c.child | |
FROM children AS c | |
UNION ALL | |
SELECT s.id, c.child | |
FROM children AS c, scions AS s | |
WHERE c.id = s.scion) | |
SELECT * FROM scions ORDER BY id, scion; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment