0
0
SQLquery~5 mins

LEFT JOIN preserving all left 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 matched rows from the right table. If there is no match, the result is NULL on the right side.
Click to reveal answer
beginner
In a LEFT JOIN, what happens if there is no matching row in the right table?
The query still returns the row from the left table, but the columns from the right table will have NULL values.
Click to reveal answer
beginner
Write a simple SQL 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
intermediate
Why is LEFT JOIN useful when you want to preserve all rows from the left table?
Because it ensures no rows from the left table are lost, even if there are no matching rows in the right table. This helps to keep all original data from the left side.
Click to reveal answer
beginner
What is the difference between INNER JOIN and LEFT JOIN?
INNER JOIN returns only rows with matching keys in both tables. LEFT JOIN returns all rows from the left table, with matching rows from the right or NULL if no match.
Click to reveal answer
What will a LEFT JOIN return if the right table has no matching rows?
AAll rows from the left table with NULLs for right table columns
BNo rows at all
COnly rows with matches in both tables
DOnly rows from the right table
Which SQL keyword is used to keep all rows from the left table regardless of matches?
ALEFT JOIN
BRIGHT JOIN
CFULL JOIN
DINNER JOIN
If you want to find customers without orders, which join helps you?
ASELF JOIN
BINNER JOIN
CCROSS JOIN
DLEFT JOIN
In a LEFT JOIN, what does a NULL in the right table columns mean?
AThere is a matching row
BThe right table is empty
CNo matching row in the right table
DThe left table has NULL values
Which join type would exclude rows from the left table if no match is found?
ALEFT JOIN
BINNER JOIN
CRIGHT JOIN
DFULL JOIN
Explain how a LEFT JOIN preserves all rows from the left table and what happens when there is no match in the right table.
Think about what happens to unmatched rows on the right side.
You got /3 concepts.
    Write a simple SQL query using LEFT JOIN to list all employees and their departments, including employees without a department.
    Use employee table as left and department table as right.
    You got /4 concepts.