An INNER JOIN returns only the rows that have matching values in both tables based on a specified condition.
SELECT A.column1, B.column2 FROM TableA A
INNER JOIN TableB B
ON A.common_column = B.common_column;
Example:
emp_id | emp_name | dept_id |
---|---|---|
1 | John | 10 |
2 | Alice | 20 |
3 | Bob | 30 |
dept_id | dept_name |
---|---|
10 | HR |
20 | Finance |
40 | Marketing |
SELECT e.emp_name, d.dept_name FROM Employees e INNER JOIN Departments d
ON e.dept_id = d.dept_id;
emp_name | dept_name |
---|---|
John | HR |
Alice | Finance |