Last active
December 19, 2017 17:33
-
-
Save ElMatella/8aaef58cc6ed6bd582d568c36b8db82f 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
Table users: | |
+----+---------+ | |
| id | name | | |
+----+---------+ | |
| 1 | Mathieu | | |
| 2 | Ynk | | |
+----+---------+ | |
Table articles: | |
+----+-----------+-------------------+ | |
| id | user_id | title | | |
+----+-----------+-------------------+ | |
| 1 | 1 | Mon super article | | |
+----+-----------+-------------------+ | |
SELECT * FROM users INNER JOIN articles ON articles.user_id = users.id | |
+---------+-----------+------------+-------------------+-------------------+ | |
| user.id | user.name | article.id | article.user_id | article.title | | |
+---------+-----------+------------+-------------------+-------------------+ | |
| 1 | Mathieu | 1 | 1 | Mon super article | | |
+---------+-----------+------------+-------------------+-------------------+ | |
SELECT * FROM users LEFT JOIN articles ON articles.user_id = users.id | |
+---------+-----------+------------+-------------------+-------------------+ | |
| user.id | user.name | article.id | article.user_id | article.title | | |
+---------+-----------+------------+-------------------+-------------------+ | |
| 1 | Mathieu | 1 | 1 | Mon super article | | |
| 2 | Ynk | null | null | null | | |
+---------+-----------+------------+-------------------+-------------------+ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment