title: mysql return default row if no row is found
body: <p>I have a table structure like this</p>
  
  <pre><code>+----+-----------+--------+
  | id | attr      | value  |
  +----+-----------+--------+
  |  1 | attr1     | val1   |
  |  2 | attr1     | val2   |
  |  2 | default   | val3   |
  |  3 | default   | val4   |
  +----+-----------+--------+
  </code></pre>
  
  <p>Here, (id, attr) is the primary key. Also, id (int), attr (varchar), value (varchar).</p>
  
  <p>I want to design a query such that for all distinct values of id I can fetch value of a specific attribute, and if it is not present for that attribute but is present as default value then return that default value.
  i_e result above table, for attr1 will be</p>
  
  <pre><code>+----+--------+
  | id | value  |
  +----+--------+
  |  1 | val1   |
  |  2 | val2   |
  |  3 | val4   |
  +----+--------+
  </code></pre>