

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 10
click for more info
Not enough gems
Cost: 6 gems
1: Joins
incomplete
2: Namespacing on Tables
incomplete
3: Left Join
incomplete
4: Right Join
incomplete
5: Full Join
incomplete
6: Joins Quiz
incomplete
7: Joins Quiz
incomplete
8: Joins Quiz
incomplete
9: Join Practice
incomplete
10: Query Practice – Support Tickets
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
A LEFT JOIN will return every record from table_a regardless of whether or not any of those records have a match in table_b. A left join will also return any matching records from table_b. Here's a Venn diagram to help visualize the effect of a LEFT JOIN:
A small trick you can do to make writing the SQL query easier is to define an alias for each table. Here's an example:
SELECT e.name, d.name
FROM employees e
LEFT JOIN departments d
ON e.department_id = d.id;
Notice the simple alias declarations e and d for employees and departments, respectively.
Some developers do this to make their queries less verbose. That said, I personally hate it because single-letter variables are harder to grok, so don't use them in this course!
The CashPal team needs a report on all the transactions a user has made. Join the users and transactions tables on users.id and transactions.user_id.