0
0
MySQLquery~10 mins

RIGHT JOIN in MySQL - 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 records from the right table and matching records from the left table using RIGHT JOIN.

MySQL
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id = departments.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 departments and their employees, including departments with no employees.

MySQL
SELECT departments.department_name, employees.name FROM departments [1] employees ON departments.id = employees.department_id;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BCROSS JOIN
CRIGHT JOIN
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT JOIN when departments is the left table.
Using INNER JOIN which excludes departments without employees.
3fill in blank
hard

Fix the error in the query to correctly use RIGHT JOIN to get all departments and their employees.

MySQL
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id = departments.id;
Drag options to blanks, or click blank then click option'
ARIGHT JOIN
BINNER JOIN
CJOIN
DLEFT JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN which excludes unmatched rows.
Using LEFT JOIN which includes all left table rows instead.
4fill in blank
hard

Fill both blanks to select all employees and their departments, including employees without departments.

MySQL
SELECT employees.name, departments.department_name FROM employees [1] departments ON employees.department_id [2] departments.id;
Drag options to blanks, or click blank then click option'
ALEFT JOIN
B=
CRIGHT JOIN
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT JOIN which excludes employees without departments.
Using '!=' in ON condition which is invalid for joins.
5fill in blank
hard

Fill all three blanks to select all departments and their employees, including departments with no employees, and order by department name.

MySQL
SELECT departments.department_name, employees.name FROM departments [1] employees ON departments.id [2] employees.department_id ORDER BY departments.department_name [3];
Drag options to blanks, or click blank then click option'
ALEFT JOIN
B=
CASC
DDESC
Attempts:
3 left
💡 Hint
Common Mistakes
Using RIGHT JOIN which excludes departments without employees.
Using DESC which orders in reverse alphabetical order.