title: SQL join format - nested inner joins
body: <p>I have the following SQL statement in a legacy system I'm refactoring. It is an abbreviated view for the purposes of this question, just returning count(*) for the time being.</p>
  
  <pre><code>SELECT COUNT(*)
  FROM Table1 
      INNER JOIN Table2 
          INNER JOIN Table3 ON Table2.Key = Table3.Key AND Table2.Key2 = Table3.Key2 
      ON Table1.DifferentKey = Table3.DifferentKey
  </code></pre>
  
  <p>It is generating a very large number of records and killing the system, but could someone please explain the syntax? And can this be expressed in any other way?</p>
  
  <ul>
  <li>Table1 contains 419 rows</li>
  <li>Table2 contains 3374 rows</li>
  <li>Table3 contains 28182 rows</li>
  </ul>
  
  <p>EDIT:</p>
  
  <p>Suggested reformat</p>
  
  <pre><code>SELECT COUNT(*)
  FROM Table1 
      INNER JOIN Table3
            ON Table1.DifferentKey = Table3.DifferentKey
      INNER JOIN Table2 
            ON Table2.Key = Table3.Key AND Table2.Key2 = Table3.Key2
  </code></pre>