title: Get total count of records with a mysql join and 2 tables
body: <p>I have 2 tables that I am trying to join but I am not sure how to make it the most time efficient.</p>
  
  <p>Tasks Table:</p>
  
  <pre><code>nid | created_by | claimed_by | urgent
  1   |     11     |     22     |   1
  2   |     22     |     33     |   1
  3   |     33     |     11     |   1
  1   |     11     |     43     |   0
  1   |     11     |     44     |   1
  </code></pre>
  
  <p>Employee Table:</p>
  
  <pre><code>userid | name
    11   |  EmployeeA
    22   |  EmployeeB
    33   |  EmployeeC
  </code></pre>
  
  <p>Result I am trying to get:</p>
  
  <pre><code>userid | created_count | claimed_count | urgent_count
    11   |       3       |       1       |       3
    22   |       1       |       1       |       2
    33   |       1       |       1       |       2
  </code></pre>
  
  <p><code>created_account</code> column will show total # of tasks created by that user.</p>
  
  <p><code>claimed_count</code> column will show total # of tasks claimed by that user.</p>
  
  <p><code>urgent_count</code> column will show total # of urgent tasks (created or claimed) by that user.</p>
  
  <p>Thanks in advance!</p>