0
0
SQLquery~10 mins

INNER JOIN with ON condition 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 join two tables on the customer_id column.

SQL
SELECT orders.order_id, customers.name FROM orders INNER JOIN customers ON orders.[1] = customers.customer_id;
Drag options to blanks, or click blank then click option'
Acustomer_id
Border_id
Cname
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not exist in both tables.
Joining on order_id instead of customer_id.
2fill in blank
medium

Complete the code to select product names and order quantities by joining orders and products tables.

SQL
SELECT products.product_name, orders.quantity FROM orders INNER JOIN products ON orders.[1] = products.product_id;
Drag options to blanks, or click blank then click option'
Aquantity
Bproduct_id
Corder_id
Dcustomer_id
Attempts:
3 left
💡 Hint
Common Mistakes
Joining on order_id instead of product_id.
Using quantity as join condition.
3fill in blank
hard

Fix the error in the join condition to correctly join employees and departments tables.

SQL
SELECT employees.name, departments.department_name FROM employees INNER JOIN departments ON employees.[1] = departments.dept_id;
Drag options to blanks, or click blank then click option'
Adepartment
Bdept_id
Cdepartment_id
Demployee_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using employee_id instead of department_id.
Using department instead of department_id.
4fill in blank
hard

Fill both blanks to join sales and customers tables and select sale_id and customer name.

SQL
SELECT sales.sale_id, customers.[1] FROM sales INNER JOIN customers ON sales.[2] = customers.customer_id;
Drag options to blanks, or click blank then click option'
Aname
Bsale_id
Ccustomer_id
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Using sale_id instead of name for the first blank.
Joining on sale_id instead of customer_id.
5fill in blank
hard

Fill all three blanks to join orders, customers, and products tables and select order_id, customer name, and product name.

SQL
SELECT orders.[1], customers.[2], products.[3] FROM orders INNER JOIN customers ON orders.customer_id = customers.customer_id INNER JOIN products ON orders.product_id = products.product_id;
Drag options to blanks, or click blank then click option'
Aorder_id
Bname
Cproduct_name
Dquantity
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting quantity instead of product_name.
Using wrong column names for customer or product.