title: Count primary table rows having at least one reference in other tables
body: <p>Assuming there are 3 tables in the database - <code>classes</code>, <code>board</code> and <code>tasks</code>. There is a FK reference of <code>class_id</code> from <code>classes</code> table in other two tables.</p>
  
  <p>There could be instances where for a particular <code>class_id</code>, there are no references in either of the two tables or could have reference in one table but not the other.</p>
  
  <p>Objective is to count all <code>classes</code> which have at least one reference in any of the two tables. </p>
  
  <p>What i have tried so far :</p>
  
  <pre><code>SELECT COUNT(c.class_id) FROM classes  as c
  LEFT JOIN board as b on b.class_id = c.class_id
  LEFT JOIN tasks as t on t.class_id = c.class_id
  </code></pre>
  
  <p>This actually returns the count of all instances in the 3 tables whereas the count should of the primary table only.</p>