Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does a RIGHT JOIN do in SQL?
A RIGHT JOIN returns all rows from the right table and the matching rows from the left table. If there is no match, the result will contain NULLs for columns from the left table.
Click to reveal answer
beginner
In a RIGHT JOIN, what happens when a row in the right table has no matching row in the left table?
The row from the right table still appears in the result, but columns from the left table will have NULL values.
Click to reveal answer
intermediate
How is a RIGHT JOIN different from a LEFT JOIN?
A RIGHT JOIN returns all rows from the right table and matching rows from the left, while a LEFT JOIN returns all rows from the left table and matching rows from the right.
Click to reveal answer
intermediate
Consider these tables: Table A: ids 1, 2 Table B: ids 2, 3 What rows will a RIGHT JOIN on id return?
It will return rows with ids 2 and 3. For id 2, matching data from both tables appears. For id 3, data from Table A will be NULL because there is no match.
Click to reveal answer
intermediate
Why might you use a RIGHT JOIN instead of a LEFT JOIN?
You use a RIGHT JOIN when you want to keep all rows from the right table regardless of matches in the left table. It depends on which table's data you want to preserve fully.
Click to reveal answer
What does a RIGHT JOIN return?
AAll rows from the right table and matching rows from the left table
BAll rows from the left table and matching rows from the right table
COnly matching rows from both tables
DAll rows from both tables
✗ Incorrect
A RIGHT JOIN returns all rows from the right table and matching rows from the left table, filling with NULLs when no match exists.
If a row in the right table has no match in the left table, what will the LEFT table columns show?
AZeroes
BThe matching values
CNULL values
DEmpty strings
✗ Incorrect
When there is no match, columns from the left table will show NULL values in the result.
Which SQL join is the opposite of RIGHT JOIN?
ALEFT JOIN
BINNER JOIN
CFULL JOIN
DCROSS JOIN
✗ Incorrect
LEFT JOIN is the opposite of RIGHT JOIN because it returns all rows from the left table and matching rows from the right.
In a RIGHT JOIN, which table's rows are always fully included?
ALeft table
BRight table
CBoth tables
DNeither table
✗ Incorrect
RIGHT JOIN always includes all rows from the right table.
What will be the result of RIGHT JOIN if both tables have no matching rows?
AAll rows from both tables
BAll rows from left table with NULLs
CEmpty result
DAll rows from right table with NULLs for left table columns
✗ Incorrect
RIGHT JOIN returns all rows from the right table, with NULLs for left table columns if no match exists.
Explain how a RIGHT JOIN works and when you would use it.
Think about which table's rows you want to keep completely.
You got /4 concepts.
Describe the difference between LEFT JOIN and RIGHT JOIN with an example.
Consider two tables with overlapping and unique ids.
You got /4 concepts.
Practice
(1/5)
1. What does a RIGHT JOIN do in SQL?
easy
A. Returns all rows from the right table and matching rows from the left table.
B. Returns all rows from the left table and matching rows from the right table.
C. Returns only rows that have matching values in both tables.
D. Returns all rows from both tables, matching where possible.
Solution
Step 1: Understand RIGHT JOIN behavior
A RIGHT JOIN returns all rows from the right table regardless of matches in the left table.
Step 2: Identify matching rows from the left table
It includes matching rows from the left table and fills NULL where no match exists.
Final Answer:
Returns all rows from the right table and matching rows from the left table. -> Option A
Quick Check:
RIGHT JOIN = all right table rows + matched left rows [OK]
Hint: Remember: RIGHT JOIN keeps all right table rows [OK]
Common Mistakes:
Confusing RIGHT JOIN with LEFT JOIN
Thinking it returns only matching rows
Assuming it returns all rows from left table
2. Which of the following is the correct syntax for a RIGHT JOIN between tables Employees and Departments on DepartmentID?
easy
A. SELECT * FROM Employees RIGHT Departments JOIN ON Employees.DepartmentID = Departments.DepartmentID;
B. SELECT * FROM Employees JOIN Departments RIGHT ON Employees.DepartmentID = Departments.DepartmentID;
C. SELECT * FROM Employees RIGHT JOIN Departments WHERE Employees.DepartmentID = Departments.DepartmentID;
D. SELECT * FROM Employees RIGHT JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID;
Solution
Step 1: Identify correct JOIN syntax
The correct syntax is: FROM left_table RIGHT JOIN right_table ON condition.
Step 2: Match the syntax with given options
SELECT * FROM Employees RIGHT JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID; correctly uses RIGHT JOIN with ON clause and proper table order.
Final Answer:
SELECT * FROM Employees RIGHT JOIN Departments ON Employees.DepartmentID = Departments.DepartmentID; -> Option D
Quick Check:
RIGHT JOIN syntax = FROM left RIGHT JOIN right ON condition [OK]
Hint: RIGHT JOIN syntax: FROM left RIGHT JOIN right ON condition [OK]
Common Mistakes:
Placing RIGHT keyword after JOIN
Using WHERE instead of ON for join condition
Incorrect table order in JOIN
3. Given tables: Employees: ID | Name | DeptID 1 | Alice | 10 2 | Bob | 20 3 | Carol | NULL
What is the result of: SELECT Employees.Name, Departments.DeptName FROM Employees RIGHT JOIN Departments ON Employees.DeptID = Departments.DeptID;?
medium
A. [('Alice', 'Sales'), ('Bob', 'Marketing'), (NULL, 'HR')]
B. [('Alice', 'Sales'), ('Bob', 'Marketing')]
C. [('Alice', 'Sales'), ('Bob', 'Marketing'), ('Carol', NULL)]
D. [('Alice', 'Sales'), ('Bob', 'Marketing'), ('Carol', 'HR')]
Solution
Step 1: Identify RIGHT JOIN effect on rows
RIGHT JOIN keeps all Departments rows (right table), matching Employees rows or NULL if no match.
Step 2: Match Employees to Departments by DeptID
DeptID 10 matches Alice, 20 matches Bob, 30 has no employee so NULL for Name.
Final Answer:
[('Alice', 'Sales'), ('Bob', 'Marketing'), (NULL, 'HR')] -> Option A
Quick Check:
RIGHT JOIN keeps all right rows, unmatched left columns NULL [OK]
Hint: RIGHT JOIN keeps all right rows, unmatched left columns NULL [OK]
Common Mistakes:
Ignoring unmatched right table rows
Assuming unmatched left rows appear
Mixing up NULL placement
4. Consider this SQL query: SELECT * FROM Orders RIGHT JOIN Customers ON Orders.CustomerID = Customers.ID; It returns fewer rows than expected. What is a likely cause?
medium
A. RIGHT JOIN always returns fewer rows than LEFT JOIN.
B. Orders table is empty, so no rows are returned.
C. The JOIN condition uses wrong column names causing no matches.
D. RIGHT JOIN syntax requires WHERE instead of ON clause.
Solution
Step 1: Analyze JOIN condition correctness
If column names in ON clause are wrong, no matches occur, reducing rows.
Step 2: Understand RIGHT JOIN behavior with no matches
RIGHT JOIN still returns all right table rows, but if condition is wrong, matches fail and left columns are NULL.
Final Answer:
The JOIN condition uses wrong column names causing no matches. -> Option C
Quick Check:
Wrong ON columns cause fewer matches [OK]
Hint: Check ON clause column names carefully [OK]
Common Mistakes:
Assuming RIGHT JOIN returns fewer rows by default
Confusing ON and WHERE clauses
Ignoring empty tables impact
5. You have two tables: Products: ProductID | Name 1 | Pen 2 | Pencil 3 | Eraser
You want a report showing all products and their sold quantities, including products with no sales (show quantity as 0). Which query correctly uses RIGHT JOIN and handles missing sales?
hard
A. SELECT Products.Name, Sales.Quantity FROM Products RIGHT JOIN Sales ON Products.ProductID = Sales.ProductID;
B. SELECT Products.Name, COALESCE(Sales.Quantity, 0) AS Quantity FROM Sales RIGHT JOIN Products ON Sales.ProductID = Products.ProductID;
C. SELECT Products.Name, COALESCE(Sales.Quantity, 0) AS Quantity FROM Products LEFT JOIN Sales ON Products.ProductID = Sales.ProductID;
D. SELECT Products.Name, Sales.Quantity FROM Sales LEFT JOIN Products ON Sales.ProductID = Products.ProductID;
Solution
Step 1: Identify which table is right and which is left
Products is the right table to keep all products; Sales is left table.
Step 2: Use RIGHT JOIN from Sales to Products and handle NULLs
RIGHT JOIN keeps all Products rows; COALESCE replaces NULL sales quantity with 0.
Final Answer:
SELECT Products.Name, COALESCE(Sales.Quantity, 0) AS Quantity FROM Sales RIGHT JOIN Products ON Sales.ProductID = Products.ProductID; -> Option B
Quick Check:
RIGHT JOIN keeps all right rows; COALESCE handles NULLs [OK]
Hint: Use COALESCE to replace NULLs after RIGHT JOIN [OK]