Skip to content

Instantly share code, notes, and snippets.

@stevenschlansker
Created July 2, 2012 16:45
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 stevenschlansker/3034187 to your computer and use it in GitHub Desktop.
Save stevenschlansker/3034187 to your computer and use it in GitHub Desktop.
create temporary table foo (key integer primary key, value integer);
insert into foo values (1,1);
insert into foo values (1,2);
insert into foo values (3,10);
WITH ids AS ( SELECT 1 AS id ) SELECT * FROM foo, ids WHERE key = ids.id OR value = ids.id;
key | value | id
-----+-------+----
1 | 1 | 1
2 | 1 | 1
(2 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment