Skip to content

Instantly share code, notes, and snippets.

@rich
Created July 21, 2009 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rich/151067 to your computer and use it in GitHub Desktop.
Save rich/151067 to your computer and use it in GitHub Desktop.
with recursive all_categories as (
select * from categories where parent_id = 3
union all
select b.* from all_categories a, categories b where a.id = b.parent_id
) select * from all_categories order by parent_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment