Skip to content

Instantly share code, notes, and snippets.

@mattm
Created November 1, 2017 18:06
Show Gist options
  • Save mattm/e7f0a62ed36139fee55db14e07addf15 to your computer and use it in GitHub Desktop.
Save mattm/e7f0a62ed36139fee55db14e07addf15 to your computer and use it in GitHub Desktop.
SELECT *
FROM users
LEFT JOIN posts ON posts.user_id = users.user_id
+---------+-------+---------+---------+
| user_id | name | post_id | user_id |
+---------+-------+---------+---------+
| 1 | Matt | 1 | 1 |
| 1 | Matt | 2 | 1 |
| 1 | Matt | 3 | 1 |
| 2 | Simon | 4 | 2 |
| 2 | Simon | 5 | 2 |
| 3 | Jen | NULL | NULL |
+---------+-------+---------+---------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment