SLSkillLoop
SQL practice

SQL JOINs Practice

JOINs help you combine related data across tables. These beginner exercises focus on reading relationships and writing clear INNER JOIN and LEFT JOIN queries.

Example practice questions

Try these samples, then continue into the SQL Practice Labfor guided browser-based practice.

1

Join orders to users using orders.user_id and users.id.

Answer: SELECT * FROM orders JOIN users ON orders.user_id = users.id;

2

Return each order id with the user's email.

Answer: SELECT orders.id, users.email FROM orders JOIN users ON orders.user_id = users.id;

3

Join products to categories using products.category_id and categories.id.

Answer: SELECT * FROM products JOIN categories ON products.category_id = categories.id;

4

Return all users, even users with no orders.

Answer: SELECT * FROM users LEFT JOIN orders ON users.id = orders.user_id;

5

Return product names and category names.

Answer: SELECT products.name, categories.name FROM products JOIN categories ON products.category_id = categories.id;

6

Join order_items to products using product_id.

Answer: SELECT * FROM order_items JOIN products ON order_items.product_id = products.id;

7

Return orders with user email where status is 'paid'.

Answer: SELECT orders.*, users.email FROM orders JOIN users ON orders.user_id = users.id WHERE orders.status = 'paid';