I am trying to join multiple tables.
Example(department_id is PK in department table and employee_id is PK in employee Table):
SELECT department.department_name, employee.employee_name
FROM employee
INNER JOIN department
ON employee.department_id = department.department_id
WHERE employee.first_name = 'John';
From the above example, how does inner join work? on each entry in employee where first_name matches as 'John' will it join with department table?
Lets say we know before hand that, we have 100 names John and 99 belong to department 1 and 1 in department 2. As we know 99% of the department table ,
is it better to query department table seperately based on department table twice
OR
Is join more efficient here even if it tries to join and get the same department information for 99% of the rows?
Appreciate the response in advance. Thanks.