title: MySQL - decrement int value, delete row if int reaches 0
body: <p>I'm trying to find a query that does the exact opposite of this:</p>
  
  <pre><code>INSERT INTO WordsTable (word, counter) 
  VALUES('$word', 1)
  ON DUPLICATE KEY UPDATE counter = counter + 1
  </code></pre>
  
  <p>(This SQL is fine. "word" is set to unique and everything)</p>
  
  <p>So, basically, decrement the counter, if the counter reaches 0, delete the whole row. I'm thinking it might look like this but I've no clue if this is valid syntax:</p>
  
  <pre><code>UPDATE WordsTable
  SET counter = counter - 1
  WHERE id='$deleteThisWord'
  IF (occ = 0) THEN
  (
      DELETE *
      FROM WordsTable
      WHERE id='$deleteThisWord'
  )
  </code></pre>
  
  <p>Is there a nice clean way to do this?</p>
  
  <p>Thanks!</p>