0
0
SQLquery~10 mins

How the join engine matches rows in SQL - Interactive 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 the two tables joined on the customer_id.

SQL
SELECT * FROM orders JOIN customers ON orders.[1] = customers.customer_id;
Drag options to blanks, or click blank then click option'
Aorder_date
Border_id
Ccustomer_id
Dproduct_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using order_id instead of customer_id in the join condition.
Joining on columns that don't relate the two tables.
2fill in blank
medium

Complete the code to perform an INNER JOIN between employees and departments on department_id.

SQL
SELECT employees.name, departments.name FROM employees [1] JOIN departments ON employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
AINNER
BRIGHT
CLEFT
DFULL
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT JOIN which includes all employees even without a department.
Using FULL JOIN which includes unmatched rows from both tables.
3fill in blank
hard

Fix the error in the join condition to correctly match orders with customers.

SQL
SELECT * FROM orders JOIN customers ON orders.[1] = customers.[2];
Drag options to blanks, or click blank then click option'
Aorder_id
Bcustomer_id
Cproduct_id
Dorder_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using order_id or product_id in the join condition causing no matches.
Using different columns on each side of the join condition.
4fill in blank
hard

Fill both blanks to select employee names and their department names using a join.

SQL
SELECT employees.[1], departments.[2] FROM employees JOIN departments ON employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
Aname
Bid
Dlocation
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting department id instead of name.
Selecting employee id instead of name.
5fill in blank
hard

Fill all three blanks to select order id, customer name, and order date from joined tables.

SQL
SELECT orders.[1], customers.[2], orders.[3] FROM orders JOIN customers ON orders.customer_id = customers.customer_id;
Drag options to blanks, or click blank then click option'
Aorder_id
Bname
Corder_date
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting customer_id instead of customer name.
Mixing columns from wrong tables.