0
0
SQLquery~5 mins

LEFT JOIN with NULL result rows in SQL - 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 shows NULL for columns from the right table.
Click to reveal answer
beginner
Why do some columns show NULL values after a LEFT JOIN?
Columns from the right table show NULL when there is no matching row for the left table's row in the right table.
Click to reveal answer
beginner
Write a simple LEFT JOIN query to get all customers and their orders, including customers with no orders.
SELECT customers.id, customers.name, orders.id AS order_id FROM customers LEFT JOIN orders ON customers.id = orders.customer_id;
Click to reveal answer
beginner
What happens if you use INNER JOIN instead of LEFT JOIN in the same query?
INNER JOIN returns only rows where there is a match in both tables. Customers without orders would be excluded.
Click to reveal answer
intermediate
How can you find rows from the left table that have no matching rows in the right table using LEFT JOIN?
Use a LEFT JOIN and then filter with WHERE right_table.column IS NULL to find unmatched rows.
Click to reveal answer
What does a LEFT JOIN return when there is no matching row in the right table?
AAn error
BNo rows at all
COnly rows from the right table
DRows with NULLs in right table columns
Which SQL clause filters rows where the right table has no match after a LEFT JOIN?
AWHERE right_table.column IS NULL
BWHERE left_table.column IS NULL
CWHERE right_table.column = 0
DWHERE left_table.column = 0
If you want all rows from the left table regardless of matches, which join do you use?
AINNER JOIN
BLEFT JOIN
CRIGHT JOIN
DFULL JOIN
What will happen if you replace LEFT JOIN with INNER JOIN in a query?
AOnly rows with matches in both tables are returned
BAll rows from the left table are returned
CAll rows from the right table are returned
DNo rows are returned
In a LEFT JOIN, what does a NULL in the right table columns indicate?
AMatching row with NULL values
BData error
CNo matching row in the right table
DLeft table row is missing
Explain how a LEFT JOIN works and why some columns might show NULL values in the result.
Think about what happens when the right table has no matching data.
You got /3 concepts.
    Describe how to find rows in the left table that have no matching rows in the right table using a LEFT JOIN.
    Filtering NULLs in right table columns helps find unmatched rows.
    You got /3 concepts.