title: mysql count records from two tables in one query?
body: <p>I have three MySQL-tables:</p>
  
  <pre><code>patient:
      paID, paCode, paAccountID (foreign key)
  
  test
      tsID, tsName, tsPatientID (foreign key), tsAccountID (foreign key)
  
  account
      acID etc.
  </code></pre>
  
  <p>Now I want to count the number of <code>paID</code> and the number of <code>tsID</code> that are linked to a specific <code>acID=1</code>. There are 6 <code>tsID</code> and 4 <code>paID</code> linked to <code>acID=1</code>.</p>
  
  <pre><code>SELECT Count(paID) AS paCount FROM patient WHERE paAccountID=1
  SELECT Count(tsID) AS tsCount FROM test WHERE tsAccountID=1
  </code></pre>
  
  <p>Tried to get both into one query...</p>
  
  <pre><code>SELECT Count(tsID) AS tsCount, Count(paID) AS paCount
  FROM test LEFT JOIN patient ON tsPatientID = paID 
  WHERE tsAccountID=1 
  </code></pre>
  
  <p>Doesn't work that way, both Counts return 6. How to get it right?</p>