Skip to content

Instantly share code, notes, and snippets.

@ryanguill
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save ryanguill/6345f547e76278422049 to your computer and use it in GitHub Desktop.

Select an option

Save ryanguill/6345f547e76278422049 to your computer and use it in GitHub Desktop.
/* useful if you dont have a real exception join */
/* this will return the records in a that are not in b on the join conditions in the left outer join */
select
a.foo
FROM
a
LEFT OUTER
JOIN b
ON a.id = b.id
WHERE
b.id IS NULL /* this must be in the where, which slows it down somewhat compared to a real exception join, but will be much faster than a NOT IN() */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment