0
0
SQLquery~10 mins

RIGHT JOIN execution behavior in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all columns from table1 and matching rows from table2 using a RIGHT JOIN.

SQL
SELECT * FROM table1 [1] table2 ON table1.id = table2.id;
Drag options to blanks, or click blank then click option'
ARIGHT JOIN
BLEFT JOIN
CINNER JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN instead of RIGHT JOIN.
Using INNER JOIN which only returns matching rows.
2fill in blank
medium

Complete the code to get all rows from the right table and matching rows from the left table where the right table's status is 'active'.

SQL
SELECT * FROM users [1] orders ON users.user_id = orders.user_id WHERE orders.status = 'active';
Drag options to blanks, or click blank then click option'
ALEFT JOIN
BRIGHT JOIN
CINNER JOIN
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which excludes unmatched rows.
Using LEFT JOIN which returns all rows from the left table.
3fill in blank
hard

Fix the error in the query to correctly perform a RIGHT JOIN between employees and departments on department_id.

SQL
SELECT employees.name, departments.name FROM employees [1] departments ON employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
BJOIN
CRIGHT JOIN
DFULL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using JOIN or INNER JOIN which excludes unmatched departments.
Using LEFT JOIN which returns all employees instead.
4fill in blank
hard

Fill both blanks to select all customers and their orders, including customers without orders, using RIGHT JOIN and aliasing.

SQL
SELECT o.order_id, c.customer_name FROM orders AS [1] [2] customers AS c ON o.customer_id = c.customer_id;
Drag options to blanks, or click blank then click option'
Ao
BLEFT JOIN
CRIGHT JOIN
Dord
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN instead of RIGHT JOIN.
Not aliasing the orders table correctly.
5fill in blank
hard

Fill all three blanks to create a RIGHT JOIN query that selects product names and their categories, including categories without products.

SQL
SELECT p.product_name, c.category_name FROM products AS [1] [2] categories AS [3] ON p.category_id = c.category_id;
Drag options to blanks, or click blank then click option'
Ap
BRIGHT JOIN
Cc
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN which excludes categories without products.
Not aliasing categories as 'c'.