title: MySQL: Typecasting NULL to 0
body: <p>Let us suppose the following table (e.g. a result of several inner join statements):</p>
  <pre><code>id | column_1 | column_2
  ------------------------
   1 |  1       | 
   2 |  2       | 2
   3 |          | 3
  </code></pre>
  <p>Which you could for example get from the following statement:</p>
  <pre><code>select a.id, t1.column_1, t2.column_2
  from a
  left join t1 on a.id = t1.id
  left join t2 on a.id = t2.id
  </code></pre>
  <p>Now, if i'd like to sum up t1.column_1 and t2.column_2 as follows</p>
  <pre><code>select 
      a.id, 
      t1.column_1, 
      t2.column_2,
      (t1.column_1 + t2.column_2) as cumulated
  from a
  left join t1 on a.id = t1.id
  left join t2 on a.id = t2.id
  </code></pre>
  <p>The result will look as follows:</p>
  <pre><code>id | column_1 | column_2 | cumulated
  ------------------------------------
   1 |  1       | NULL     | NULL
   2 |  2       | 2        | 4
   3 |  NULL    | 3        | NULL
   
  </code></pre>
  <p>My question basically is: is there a way to typecast NULL into 0 in order to do some math?</p>
  <p>I have tried <code>CONVERT(t1.column_1, SIGNED)</code> and <code>CAST(t1.column_1 as SIGNED)</code>, but a <code>NULL</code> stays a <code>NULL</code>.</p>