title: Count on multiple tables with missing zero counts
body: <p>I am running this query to return data with count &lt; 0. It works fine until count is > 0 and &lt; 50. But when count becomes 0, it doesnot return the data. Count is defined by <code>coupons`.`status</code>. On count zero, there will be no data in <code>coupons</code> table with <code>status</code> as 1. This is creating the issue, as it omits the whole row.</p>
  
  <pre><code>SELECT count(*) AS count, clients.title, plans.name 
  FROM `coupons`
      INNER JOIN `clients` ON `coupons`.`client_id` = `clients`.`id`  
      INNER JOIN `plans` ON `coupons`.`plan_id` = `plans`.`id`
  WHERE `coupons`.`status` = 1
  GROUP BY `coupons`.`client_id`, `coupons`.`plan_id` 
  HAVING count &lt; 50
  </code></pre>
  
  <p>Please help how to fix it.</p>
  
  <p>Table definitions.</p>
  
  <pre><code>coupons (id, client_id, plan_id, customer_id, status, code)
  plans (id, name)
  clients (id, name...)
  client_plans (id, client_id, plan_id)
  </code></pre>
  
  <p>Basically, a client can have multiple plans and a plan can belong to multiple clients.</p>
  
  <p>Coupons table stores predefined coupons which can be allocated to customers. Non allocated coupons have status as <code>0</code>, while as allocated coupons get status as <code>1</code></p>
  
  <p>Here I am trying to fetch non allocated client wise, plan wise coupon count where either the count is less than 50 or count has reached 0</p>
  
  <p>For example,</p>
  
  <p>If coupons table as 10 rows of client_id = 1 &amp; plan_id = 1 with status as 1, it should return count as 10, but when the table has 0 rows with client_id = 1 and plan_id = 1 with status as 1, it does not return anything in the above query.</p>