title: MySQL : Get status (pending and approved) count for each user
body: <p>I am working on a project and I'm stuck on a point. The issue is I have the following two tables, <code>users</code> and <code>user_mistakes</code>:</p>
  <p><strong><code>users</code></strong>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>ABC</td>
  </tr>
  <tr>
  <td>2</td>
  <td>XYZ</td>
  </tr>
  <tr>
  <td>3</td>
  <td>JKL</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong><code>user_mistakes</code></strong>:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>user_id</th>
  <th>mistake</th>
  <th>status</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>Lorem ipsum</td>
  <td>1</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1</td>
  <td>Lorem ipsum</td>
  <td>1</td>
  </tr>
  <tr>
  <td>3</td>
  <td>2</td>
  <td>Lorem ipsum</td>
  <td>0</td>
  </tr>
  <tr>
  <td>4</td>
  <td>2</td>
  <td>Lorem ipsum</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>If <code>user_mistakes.status = 0</code> = <strong>pending</strong></p>
  <p>If <code>user_mistakes.status = 1</code> = <strong>approved</strong></p>
  <p>According to the above <code>users</code> and <code>user_mistakes</code> table data, <strong>I want pending and approved status count</strong> for each user as a follows:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>user_id</th>
  <th>name</th>
  <th>pending_mistakes</th>
  <th>approved_mistakes</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>ABC</td>
  <td>0</td>
  <td>2</td>
  </tr>
  <tr>
  <td>2</td>
  <td>XYZ</td>
  <td>1</td>
  <td>1</td>
  </tr>
  <tr>
  <td>3</td>
  <td>JKL</td>
  <td>0</td>
  <td>0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is there any way that I can achieve this with single query?</p>