title: MySQL COUNT on multiple relations
body: <p>I am trying to figure out how to return the counts of multiple different items in seperate tables related to the table i am joining too. </p>
  
  <p>Im quite new to joins so im not sure if im using correct join. hopefully you can help me!</p>
  
  <p>the tables would be like this:</p>
  
  <p>staff_type table</p>
  
  <pre><code>id        type
  1         doctor
  2         nurse
  3         surgeon
  </code></pre>
  
  <p>staff table</p>
  
  <pre><code>id        type_id        name
  1         1              bob
  2         1              jane
  3         2              phil
  4         2              esther
  5         3              michael jackson
  </code></pre>
  
  <p>im tring to construct a statement that will return me the COUNT off the various different staff types, as in how many dactors, how many nurses etc. I also want the query to bring the data from the staff_type table.</p>
  
  <p>I haven't much ideas on how to construct this query, but it may look something like this:</p>
  
  <pre><code>SELECT staff_type.*, COUNT(Staff.type_id = staff_type.id)
  INNER JOIN staff AS Staff ON (staff_type.id = Staff.type_id)
  </code></pre>
  
  <p>i know this is nothing like what its supposed to be, bit hopefully some of you can point me in the right direction. Other posts on this topic are hard for me to understand and look like they are trying to do something slightly different.</p>
  
  <p>thanks for any help!</p>