*** CAUTION ***
That query works in this particular instance, but it will fail in most other situations.
When you use a condition in the WHERE clause that refers to the *dependent* table in an outer join (that is, the RIGHT table in a LEFT JOIN, for example), you just converted that outer join into an INNER join!!!
The sole exception to this rule is when the condition you are testing is IS NULL
(or IS NOT NULL
) as Bubikol is doing here.
For other conditions, you *MUST* move the condition on the dependent table to the ON
section of the query, thus (just an example, not applicable to this case):
FROM Employees E
LEFT JOIN EmpDepts ED
ON E.id = ED.emp_id AND ED.dept_no <> 17
WHERE E.company_index = 63
If the part of the condition there in red were moved to the WHERE, you would no longer have a LEFT JOIN.
Again, not relevant in this case, but a fair warning for the future.