title: MySql, return default value if no rows returned
body: <p>I have a query as below</p>
  
  <pre><code>SELECT cap_id FROM cap_master WHERE   
          (cap_type = 'Type1' AND cap_desc = 'CapDesc1') 
       OR (cap_type = 'Type2' AND cap_desc = 'CapDesc2')
       OR (cap_type = 'Type3' AND cap_desc = 'CapDesc3')
       OR (cap_type = 'Type4' AND cap_desc = 'CapDesc4')
  order by cap_type,cap_desc
  </code></pre>
  
  <p>This returns multiple rows based on <strong>where</strong> condition, what i am looking for is like for a condition which do not return any rows, i should have a default value say '0'. As of now i do not get any row for it.</p>
  
  <p>For e.g if 3rd condition (<em>cap_type = 'Type3' AND cap_desc = 'CapDesc3'</em>) do not match, i am expecting an output as below:</p>
  
  <pre><code>23
  34
  0  
  45
  </code></pre>
  
  <p>I checked solutions given, like </p>
  
  <p><a href="https://stackoverflow.com/questions/25000017/return-a-value-if-no-rows-match">Return a value if no rows match</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23558295/return-default-value-if-no-row-found-mysql">Return Default value if no row found -mysql</a></p>
  
  <p>But seems they don't work on multiple rows getting returned. Any pointers will be greatly appreciated.</p>
  
  <p>Here's a <a href="http://sqlfiddle.com/#!9/4b9bb0/2" rel="nofollow noreferrer">Fiddle</a> to play with.</p>