title: COUNT function and INNER JOIN on multiple tables
body: <p>This is so complicated (for me) because I usually only work with single table and simple queries (SELECT, INSERT, UPDATE), but now I am in a situation where I am stuck.</p>
  
  <ul>
  <li>What I am trying to archive is that: when a project manager logged-into his/her account, a grid-view will show a quick overview for all of his/her projects (id, created date, name and how many files are in pending) like below picture:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/xQoAY.png" alt="enter image description here"></p>
  
  <ul>
  <li>3 tables will be involved are:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/K1B1k.png" alt="enter image description here"> </p>
  
  <ul>
  <li>Sample data for manager_id = 11:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/v3vxl.png" alt="enter image description here"></p>
  
  <p>I tried this query but it not worked, it seems to display all columns right but the COUNT pending files column (assume the manager_id = 11)</p>
  
  <pre><code>SELECT COUNT(file_id) as 'Pending files', projects.project_id, projects.project_name, projects.status, projects.start_date
  FROM ((project_manager 
  INNER JOIN files 
  ON project_manager.mag_id = files.manager_id AND project_manager.mag_id = 11 AND file_status = 'Pending')
  INNER JOIN projects
  ON projects.project_id = project_manager.project_id)
  GROUP BY projects.project_id, projects.project_name, projects.status, projects.start_date
  ORDER BY projects.status, projects.start_date DESC
  </code></pre>
  
  <ul>
  <li>my query result:</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/06rq5.png" alt="enter image description here"></p>
  
  <p>I need help with a correct query and if you can explain it a little bit that would be much appreciated!</p>