Skip to content

Instantly share code, notes, and snippets.

@SAbhaya
Last active November 3, 2021 22:27
Show Gist options
  • Save SAbhaya/8302f0c2c5eb7877aa09b24081607790 to your computer and use it in GitHub Desktop.
Save SAbhaya/8302f0c2c5eb7877aa09b24081607790 to your computer and use it in GitHub Desktop.
SQL Quick Ref

https://www.codeproject.com/Articles/33052/Visual-Representation-of-SQL-Joins

Inner JOIN

SELECT <select_list> 
FROM Table_A A
INNER JOIN Table_B B
ON A.Key = B.Key

left JOIN

SELECT <select_list>
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key

right JOIN

SELECT <select_list>
FROM Table_A A
RIGHT JOIN Table_B B
ON A.Key = B.Key

outer JOIN

SELECT <select_list>
FROM Table_A A
FULL OUTER JOIN Table_B B
ON A.Key = B.Key

Left Excluding JOIN

SELECT <select_list> 
FROM Table_A A
LEFT JOIN Table_B B
ON A.Key = B.Key
WHERE B.Key IS NULL

Right Excluding JOIN

SELECT <select_list>
FROM Table_A A
RIGHT JOIN Table_B B
ON A.Key = B.Key
WHERE A.Key IS NULL

Outer Excluding JOIN

SELECT <select_list>
FROM Table_A A
FULL OUTER JOIN Table_B 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