title: When would you INNER JOIN a LEFT JOINed table /
body: <p>I came across below code today.</p>
  
  <pre><code>SELECT StaffGroup.*
  FROM StaffGroup
  LEFT OUTER JOIN StaffByGroup 
    ON StaffByGroup.StaffGroupId = StaffGroup.StaffGroupId
  INNER JOIN StaffMember 
     ON StaffMember.StaffMemberId = StaffByGroup.StaffMemberId
  WHERE StaffByGroup.StaffGroupId IS NULL
  </code></pre>
  
  <p>The main table <code>StaffGroup</code> is being LEFT JOINed with <code>StaffByGroup</code> table and then <code>StaffByGroup</code> table is being INNER JOINed with <code>StaffMember</code> table.</p>
  
  <p>I thought the INNER JOIN is trying to filter out the records which exist in <code>StaffGroup</code> and <code>StaffByGroup</code> but do not exist in <code>StaffMember</code>.</p>
  
  <p>But this is not how it is working. The query does not return any records.</p>
  
  <p>Am I missing something in understanding the logic of the query ? Have you ever used INNER JOIN with a table which has been used with LEFT JOIN in earlier part of the query ?</p>