Skip to content

Instantly share code, notes, and snippets.

@tbuckel
Created March 27, 2014 01:52
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 tbuckel/9798327 to your computer and use it in GitHub Desktop.
Save tbuckel/9798327 to your computer and use it in GitHub Desktop.
SQL Insert only of not exists
INSERT INTO example_table
(id, name)
SELECT 1, 'John'
WHERE
NOT EXISTS (
SELECT id FROM example_table WHERE id = 1
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment