← 30 Days of SQL
Day 6 / 30JOINs

INNER JOIN

JOINs are the heart of relational databases. INNER JOIN is the most common — expect 3–4 JOIN questions in every data analyst interview.

1
Easy

What is an INNER JOIN and when do you use it?

SQL Answer
SELECT e.name, d.department_name
FROM employees e
INNER JOIN departments d
  ON e.department_id = d.id;
💡

INNER JOIN returns only rows where the ON condition matches in BOTH tables. Rows with no match in either table are excluded.

2
Easy

Join employees with their department names and filter for salary > 50000.

SQL Answer
SELECT e.name, e.salary, d.department_name
FROM employees e
INNER JOIN departments d
  ON e.department_id = d.id
WHERE e.salary > 50000
ORDER BY e.salary DESC;
💡

You can add WHERE, ORDER BY, and other clauses after the JOIN. Always alias table names (e, d) when joining to avoid ambiguity.

3
Medium

Find employees along with their manager name (both from same employees table).

SQL Answer
SELECT e.name AS employee,
       m.name AS manager
FROM employees e
INNER JOIN employees m
  ON e.manager_id = m.id;
💡

This is a SELF JOIN — joining a table to itself. Used when hierarchical data (manager-employee) is in the same table. Very common interview question.

4
Medium

Join orders, customers, and products tables to get order details.

SQL Answer
SELECT o.order_id,
       c.customer_name,
       p.product_name,
       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. Each JOIN adds another table. The order of JOINs matters for readability but not (usually) for correctness.

5
Medium

Count the number of employees in each department using a JOIN.

SQL Answer
SELECT d.department_name,
       COUNT(e.id) AS emp_count
FROM departments d
INNER JOIN employees e
  ON d.id = e.department_id
GROUP BY d.department_name
ORDER BY emp_count DESC;
💡

Combining JOIN with GROUP BY is extremely common in reporting queries. Notice departments with no employees won't appear — use LEFT JOIN if you need them.

6
Easy

What is the difference between JOIN and INNER JOIN?

SQL Answer
-- These are identical — JOIN defaults to INNER JOIN:
SELECT * FROM a JOIN b ON a.id = b.id;
SELECT * FROM a INNER JOIN b ON a.id = b.id;
💡

JOIN without a type keyword is always INNER JOIN. Writing INNER JOIN explicitly is better practice for readability.

EVIKA ACADEMY · SQL FOR DATA ANALYTICS

Want to master SQL with live practice?

Join our SQL for Data Analytics course — live classes in Noida and online across India.

Book Free Demo Class →
← PREVIOUSDay 5: GROUP BY Deep DiveNEXT →Day 7: LEFT JOIN and RIGHT JOIN
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY