title: understand IFNULL mysql
body: <p>I am trying to understand <code>IFNULL</code> query when its wrapped in a case statement. I feel like there is redundancy want to understand bit more in detail. </p>
  
  <pre><code>SELECT user_id, 
         (CASE WHEN IFNULL(condition,1) = 0 THEN 1 ELSE IFNULL(condition,1) END)::int adjusted_condition, TRANSACT_ID
  FROM user_transaction
  </code></pre>
  
  <p>When I am trying to understand the by breaking down
  <code>IFNULL(condition,1)</code> = This basically assign <code>1</code> to condition when condition is <code>NULL</code></p>
  
  <p>Here is the data without the case statement: </p>
  
  <pre><code>+---------+-----------+-------------+                                           
  | USER_ID | CONDITION | TRANSACT_ID |
  |---------+-----------+-------------|
  |       1 | NULL      |      40779 |
  |       4 | NULL      |      40779 |
  |       1 | 1         |      40855 |
  |       2 | 1         |      40855 |
  |       1 | 1         |      40864 |
  |       2 | 1         |      40864 |
  |       1 | 1         |      40876 |
  |       2 | 4         |      40876 |
  |       3 | 4         |      40876 |
  |       4 | 4         |      40876 |
  +---------+-----------+-------------+
  </code></pre>