community/learn/content/01-SQL-Basics/03-joins/01-inner-join.md
In this exercise we will query the employees table using an INNER JOIN with the orders table.
SELECT DISTINCT employees.employee_id,
employees.last_name,
employees.first_name,
employees.title
FROM employees
INNER JOIN orders ON employees.employee_id = orders.employee_id;
The query should return 9 rows.
In this exercise we will query the employees table by using an INNER JOIN with the orders table and order the results by product_id in a descending order.
SELECT DISTINCT products.product_id,
products.product_name,
order_details.unit_price
FROM products
INNER JOIN order_details ON products.product_id = order_details.product_id
ORDER BY products.product_id DESC;
The query should return 156 rows.
In this exercise we will query the products table by using an INNER JOIN with the order_details table where the product_id equals 2.
SELECT DISTINCT products.product_id,
products.product_name,
order_details.order_id
FROM products
INNER JOIN order_details ON products.product_id = order_details.product_id
WHERE products.product_id = 2;
The query should return 44 rows.
In this exercise we will query the orders table by using an INNER JOIN with the customers and _employees_table.
SELECT customers.company_name,
employees.first_name,
orders.order_id
FROM orders
INNER JOIN customers ON customers.customer_id = orders.customer_id
INNER JOIN employees ON employees.employee_id = orders.employee_id;
The query should return 830 rows.