Skip to content

Instantly share code, notes, and snippets.

@andreypopp
Created January 25, 2011 17:27
Show Gist options
  • Save andreypopp/795262 to your computer and use it in GitHub Desktop.
Save andreypopp/795262 to your computer and use it in GitHub Desktop.
psql=# table b;
l │ r
───┼───
a │ b
b │ e
e │ d
(3 rows)
Time: 0.188 ms
psql=# with recursive c as (select * from b union select b.l, c.r from b join c on c.l = b.r) table c;
l │ r
───┼───
a │ b
b │ e
e │ d
a │ e
b │ d
a │ d
(6 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment