0
0
MySQLquery~5 mins

LEFT JOIN in MySQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does a LEFT JOIN do in SQL?
A LEFT JOIN returns all rows from the left table and the matching rows from the right table. If there is no match, the result will contain NULL for columns from the right table.
Click to reveal answer
beginner
Write the basic syntax of a LEFT JOIN.
SELECT columns FROM left_table LEFT JOIN right_table ON left_table.key = right_table.key;
Click to reveal answer
intermediate
Why might you use a LEFT JOIN instead of an INNER JOIN?
Use LEFT JOIN when you want to keep all records from the left table, even if there are no matching records in the right table. INNER JOIN only returns rows with matches in both tables.
Click to reveal answer
beginner
In a LEFT JOIN, what happens if the right table has no matching row?
The columns from the right table will contain NULL values for that row in the result.
Click to reveal answer
intermediate
Can a LEFT JOIN return more rows than the left table originally has? Why or why not?
Yes, if a single row in the left table matches multiple rows in the right table (one-to-many relationship). A LEFT JOIN always returns at least as many rows as the left table, since every left row is included at least once.
Click to reveal answer
What does a LEFT JOIN include in its result?
AOnly rows from the right table
BOnly rows that match in both tables
CAll rows from the right table and matching rows from the left table
DAll rows from the left table and matching rows from the right table
If a row in the left table has no match in the right table, what will the right table columns show?
ANULL
BZero
CEmpty string
DError
Which SQL keyword is used to perform a LEFT JOIN?
AINNER JOIN
BLEFT JOIN
CRIGHT JOIN
DFULL JOIN
Can a LEFT JOIN result have fewer rows than the left table?
AYes, if the right table has no matches
BNo, it always has more rows
CNo, it always has the same or more rows
DYes, if the left table is empty
Which join would you use to keep all rows from the left table regardless of matches?
ALEFT JOIN
BINNER JOIN
CRIGHT JOIN
DCROSS JOIN
Explain in your own words what a LEFT JOIN does and when you might use it.
Think about keeping all your main list and adding details if available.
You got /4 concepts.
    Describe the difference between LEFT JOIN and INNER JOIN with an example scenario.
    Imagine a list of customers and their orders.
    You got /4 concepts.