Skip to content

Instantly share code, notes, and snippets.

@nomeyer
Last active March 3, 2016 11:47
Show Gist options
  • Save nomeyer/8f264ad6ff85ac480151 to your computer and use it in GitHub Desktop.
Save nomeyer/8f264ad6ff85ac480151 to your computer and use it in GitHub Desktop.
Combine queries using the union, intersection, or difference operators (from http://www.postgresql.org/docs/9.4/static/queries-union.html)
(select ... from ...) foo union (select ... from ...) bar;
(select ... from ...) foo intersect (select ... from ...) bar;
(select ... from ...) foo except (select ... from ...) bar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment