Created
November 1, 2017 18:13
-
-
Save mattm/662ae39af929400466c2e9a0eca3d3ca to your computer and use it in GitHub Desktop.
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
SELECT * | |
FROM users | |
LEFT JOIN posts ON posts.user_id = users.user_id | |
LEFT JOIN pages ON pages.user_id = users.user_id | |
+---------+-------+---------+---------+---------+---------+ | |
| user_id | name | post_id | user_id | page_id | user_id | | |
+---------+-------+---------+---------+---------+---------+ | |
| 2 | Simon | 4 | 2 | 1 | 2 | | |
| 2 | Simon | 5 | 2 | 1 | 2 | | |
| 2 | Simon | 4 | 2 | 2 | 2 | | |
| 2 | Simon | 5 | 2 | 2 | 2 | | |
| 1 | Matt | 1 | 1 | NULL | NULL | | |
| 1 | Matt | 2 | 1 | NULL | NULL | | |
| 1 | Matt | 3 | 1 | NULL | NULL | | |
| 3 | Jen | NULL | NULL | 3 | 3 | | |
| 3 | Jen | NULL | NULL | 4 | 3 | | |
| 3 | Jen | NULL | NULL | 5 | 3 | | |
| 3 | Jen | NULL | NULL | 6 | 3 | | |
| 3 | Jen | NULL | NULL | 7 | 3 | | |
+---------+-------+---------+---------+---------+---------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment