Created
March 24, 2016 16:35
-
-
Save jimytc/f11c3d31b7d7212917ff to your computer and use it in GitHub Desktop.
Use INSERT with LEFT JOIN to achieve UPSERT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO creation_metadata (creation_id, category) | |
SELECT creations.id, creations.type | |
FROM creations | |
LEFT JOIN creation_metadata | |
ON creations.id = creation_metadata.creation_id | |
WHERE creations.type IS NOT NULL | |
AND creation_metadata.category IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment