Last active
August 29, 2015 14:23
-
-
Save cadrev/9980fcc2324e2a796ec9 to your computer and use it in GitHub Desktop.
A cheatsheet for sql joins
This file contains 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
-- Inner Join | |
SELECT * FROM A INNER JOIN B ON A.key = B.key | |
-- Left Join | |
SELECT * FROM A LEFT JOIN B ON A.key = B.key | |
-- Left Join without Intersection | |
SELECT * FROM A INNER JOIN B ON A.key = B.key where B.key IS NULL | |
-- Right Join | |
SELECT * FROM A RIGHT JOIN B ON A.key = B.key | |
-- Right Join without Intersection | |
SELECT * FROM A RIGHT JOIN B ON A.key = B.key where B.key IS NULL | |
-- Full Join | |
SELECT * FROM A FULL JOIN B ON A.key = B.key | |
-- Full Join without intersection | |
SELECT * FROM A FULL JOIN B ON A.key = B.key where A.key IS NULL OR B.key IS NULL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment