title: MySQL - After Insert Trigger that updates two tables?
body: <p>I have a problem with a MySQL Trigger.
  I have 3 tables <strong>Customers</strong>, <strong>Products</strong> and <strong>Sales</strong>.
  In <strong>Sales</strong> I reference <strong>customer</strong> and <strong>product</strong> and I want to update the some counts on <strong>Products</strong> and <strong>Customers</strong> after a new sale is inserted.
  The following trigger fails to update both tables... I cannot figure out what I am doing wrong.</p>
  
  <pre><code>DELIMITER $
  CREATE TRIGGER OnSalesInsert AFTER INSERT ON Sales
  FOR EACH ROW BEGIN
   UPDATE Products SET Products.sold=Products.sold+NEW.amount WHERE Products.id=NEW.product_id;
   UPDATE Customers SET Customers.amount=Customers.amount+NEW.amount WHERE Customers.id=NEW.customer_id;
  END $
  DELIMITER ;
  </code></pre>