It is not clear to me what is the behaviour of a LEFT JOIN if you try to JOIN on a column that may be NULL.
E.g.
SELECT columns
FROM
EmployeePayment ep JOIN EmployeePaymentGroup g ON g.group_id = ep.group_id AND g.subsidiary_id = ep.subsidiary_id
LEFT JOIN EmployeeSalaryDetails esd USING (department_id)
LEFT JOIN Employee e ON e.id = esd.emp_id
What happens if the INNER JOIN of EmployeePayment and EmployeePaymentGroup return 1 record and then the second LEFT JOIN on EmployeeSalaryDetails retains this record but this record has as esd.emp_id a NULL value and try to LEFT JOIN on Employee on that NULL value.
I know that NULLs are tricky so I was wondering how does the LEFT JOIN cope with NULLs
Note:
I opened a question earlier about JOINs but the comment of Abhik Chakraborty make me realise that there was a problem with a NULL value in a condition