title: Trigger to Calculate Total Cost from Units and Price
body: <p>I'm enjoying all that MySQL can do.  I want to learn how I can have a MySQL Trigger to update the Total Cost of a MySQL column where UNITS * PRICE will (of course) equal total cost.</p>
  
  <p>INVOICE TABLE includes (
  Price,
  Units,
  Total Cost)</p>
  
  <pre><code>    CREATE TRIGGER TRG_TOTAL_COST 
      AFTER INSERT ON INVOICE
      FOR EACH ROW 
      BEGIN 
      --1) Get the TOTAL
      SELECT TOTAL_COST from INVOICE
      --2) Compute total
      TOTAL_COST= UNITS * 
      PRICE; 
      END;
  </code></pre>