title: CASE WHEN NULL in MySQL
body: <p>I'm trying to set item quantity to 0 if it's <code>NULL</code> in <code>item_to_inv</code></p>
  <pre><code>SELECT
    i.`id`,
    (
      SELECT
        SUM(
          CASE
            WHEN (
              `quantity` &lt; 0
              OR `quantity` IS NULL
            ) THEN 0
            ELSE `quantity`
          END
        ) AS `quantity`
      FROM
        `item_to_inv`
      WHERE
        `item_id` = i.`id`
      GROUP BY
        `item_id`
    ) AS `quantity`
  FROM
    `item` AS `i`
  </code></pre>
  <p>The following item ids: 5, 8 and 10 has not records in <code>item_to_inv</code></p>
  <p>What's wrong in following CASE WHEN statement?</p>
  <pre><code>CASE WHEN (`quantity` &lt; 0 OR `quantity` IS NULL) THEN 0
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VXZ9O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VXZ9O.jpg" alt="enter image description here" /></a></p>