title: MySQL Trigger cannot update table - getting ERROR 1442
body: <p>I have the following trigger:</p>
  
  <pre><code>CREATE TRIGGER sum
  AFTER INSERT
  ON news
  FOR EACH ROW
  UPDATE news SET NEW.sum = (NEW.int_views + NEW.ext_views)/NEW.pageviews
  </code></pre>
  
  <p>It sums the <code>int_views</code> and <code>ext_views</code> column of a table and divides them by the total pageviews.</p>
  
  <p>Whenever I try to add a new row to news, I get the following error:</p>
  
  <pre><code>ERROR 1442 (HY000) at line 3: Can't update table 'news' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
  </code></pre>
  
  <p>The trigger seems pretty simple to me. Is there a reason why the trigger fails to run?</p>