This guide is specifically for SQL Server syntax.
Intermediate-level SQL INNER JOIN practice exercises with solutions.
Exercise 1
Question: Join employees with their departments to show employee name and department name.
SELECT e.name AS employee_name, d.name AS department_name FROM employees e INNER JOIN departments d ON e.department_id = d.id;
INNER JOIN returns only rows that have matching values in both tables. Use table aliases (e, d) for cleaner code.
Exercise 2
Question: Find all orders with their customer names and product names.
SELECT c.name AS customer, p.name AS product, o.quantity FROM orders o INNER JOIN customers c ON o.customer_id = c.id INNER JOIN products p ON o.product_id = p.id;
You can chain multiple JOINs to connect several tables. Each JOIN adds one more table to the result.
SQL Server-Specific Notes
This page covers SQL Server syntax. Other databases may have different syntax for similar operations.