0
0
SQLquery~10 mins

Why understanding relationships matters in SQL - Test Your Understanding

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 employees table.

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
AALL
B*
Cemployees
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of '*' to select all columns.
Using 'ALL' which is not valid in this context.
2fill in blank
medium

Complete the code to join the orders table with customers on customer_id.

SQL
SELECT orders.order_id, customers.name FROM orders JOIN customers ON orders.[1] = customers.customer_id;
Drag options to blanks, or click blank then click option'
Acustomer_id
Border_id
Cname
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using order_id instead of customer_id for the join condition.
Using a column that does not exist in the orders table.
3fill in blank
hard

Fix the error in the join condition to correctly link products and categories.

SQL
SELECT products.name, categories.name FROM products JOIN categories ON products.[1] = categories.id;
Drag options to blanks, or click blank then click option'
Aname
Bproduct_id
Cid
Dcategory_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using products.id instead of products.category_id.
Using categories.name instead of categories.id.
4fill in blank
hard

Fill both blanks to create a query that finds all orders with their customer's name.

SQL
SELECT orders.order_id, customers.[1] FROM orders JOIN customers ON orders.[2] = customers.customer_id;
Drag options to blanks, or click blank then click option'
Aname
Border_id
Ccustomer_id
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using orders.order_id instead of customers.name.
Joining on orders.order_id instead of orders.customer_id.
5fill in blank
hard

Fill all three blanks to select product names and their category names where category id is greater than 5.

SQL
SELECT products.[1], categories.[2] FROM products JOIN categories ON products.[3] = categories.id WHERE categories.id > 5;
Drag options to blanks, or click blank then click option'
Aname
Bcategory_id
Dproduct_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using product_id instead of category_id for the join.
Selecting wrong columns that do not exist.