title: How can i Update inventory using TRIGGER
body: <p>Well here is the problem...I want to update the inventory table at my database which includes                </p>
  
  <pre><code>Sale(ProductID,Quantity,Price)                 
  Invlevel(ProductID,Quantity)
  </code></pre>
  
  <p>I want to use triggers for this update. I have to use 2 triggers (I think). 1 at the sale tables which will be something like</p>
  
  <pre><code>CREATE TRIGGER `sale_AINS` AFTER INSERT ON sale FOR EACH ROW
  begin
  update Invlevel set quantity = Invlevel.quantity-"sale.quantity" where
  Invlevel.ProductID = "sale.ProductID";
  END
  </code></pre>
  
  <p>with this trigger, when a sale comes up, I want to adjust the inventory level at the product which the sale came to. However, even though this trigger has no errors and runs properly when I insert into sale table, it doesn't make any changes at the Invlevel table and I don't know why ( :@ ).</p>
  
  <p>Moreover, I made the trigger at the Invlevel table like that</p>
  
  <pre><code>CREATE TRIGGER `invlevel_AUPD` after UPDATE on invlevel FOR EACH ROW
  if invlevel.quantity &lt; 20 
  begin
  insert into orders 
  (select productid,amount from reorder where reorder.productid = invlevel.productid )
  end
  </code></pre>
  
  <p>*(orders,reorder are other tables)</p>
  
  <p>It says to me I have syntax error which I don't know what it is and also even if I find it I can't even check the logic because the other trigger isn't even working... Any thought or help about it would be really helpful.</p>