0
0
SQLquery~10 mins

Natural join and its risks 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 perform a natural join between tables employees and departments.

SQL
SELECT * FROM employees [1] departments;
Drag options to blanks, or click blank then click option'
ANATURAL JOIN
BINNER JOIN ON
CLEFT JOIN
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using INNER JOIN without ON clause causes syntax error.
Using CROSS JOIN returns all combinations, not matching rows.
2fill in blank
medium

Complete the code to find all employees with their department names using natural join.

SQL
SELECT employee_name, department_name FROM employees [1] departments;
Drag options to blanks, or click blank then click option'
ALEFT JOIN ON employees.department_id = departments.department_id
BNATURAL JOIN
CRIGHT JOIN ON employees.department_id = departments.department_id
DFULL JOIN ON employees.department_id = departments.department_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN without ON clause causes error.
Using RIGHT JOIN or FULL JOIN when natural join is intended.
3fill in blank
hard

Fix the error in the natural join query that causes unexpected results due to extra common columns.

SQL
SELECT * FROM employees [1] departments;
Drag options to blanks, or click blank then click option'
ALEFT JOIN ON employees.department_id = departments.department_id
BNATURAL JOIN
CINNER JOIN ON employees.department_id = departments.department_id
DCROSS JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Continuing to use NATURAL JOIN without checking common columns.
Using CROSS JOIN which returns all combinations.
4fill in blank
hard

Fill both blanks to create a safe join avoiding natural join risks and selecting employee and department names.

SQL
SELECT employees.employee_name, departments.department_name FROM employees [1] departments [2] employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
AINNER JOIN
BLEFT JOIN
CON
DUSING
Attempts:
3 left
💡 Hint
Common Mistakes
Using NATURAL JOIN instead of INNER JOIN.
Using USING keyword which can still cause issues if column names differ.
5fill in blank
hard

Fill all three blanks to write a query that joins employees and departments safely, selecting employee name, department name, and filtering by department location.

SQL
SELECT [1], [2] FROM employees [3] departments ON employees.department_id = departments.department_id WHERE departments.location = 'New York';
Drag options to blanks, or click blank then click option'
Aemployees.employee_name
Bdepartments.department_name
CINNER JOIN
DNATURAL JOIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using NATURAL JOIN which may join on unintended columns.
Selecting columns without table prefixes causing ambiguity.