Skip to content

Instantly share code, notes, and snippets.

@CloCkWeRX
Created January 16, 2013 23:34
Show Gist options
  • Save CloCkWeRX/4552043 to your computer and use it in GitHub Desktop.
Save CloCkWeRX/4552043 to your computer and use it in GitHub Desktop.
Have a data set with a 'parent' and 'child' column, storing paths through a tree (see http://fungus.teststation.com/~jon/treehandling/TreeHandling.htm for the modelling). At the moment, there's a stored proc that takes exactly one ID and builds a data set like the below. Trying to neatly re-write this as a view, so that I can simply add in the "…
SELECT
*
FROM data
WHERE id IN(
SELECT @id
UNION
SELECT child_id FROM paths WHERE parent_id = @id
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment