Skip to content

Instantly share code, notes, and snippets.

View dataserver's full-sized avatar
💤
vacation

John dataserver

💤
vacation
View GitHub Profile
@dataserver
dataserver / closure-table-operations.sql
Created March 4, 2019 16:35 — forked from kentoj/closure-table-operations.sql
Closure Table operations SQL fragments
-- Retrieve descendants
-- ====================
-- retrieve descendants of #4
SELECT c.*
FROM Comments AS c
JOIN TreePaths AS t ON c.comment_id = t.descendant
WHERE t.ancestor = 4;
-- Retrieve ancestors