title: How to populate a table when another table is populated?
body: <p>I want the table <strong>cart</strong> to be populated when I populate the table <strong>cart_utilizador</strong> and the table <strong>cart</strong> will be populated with <code>CURDATE();</code> on the field <em>datas</em>. How can I achieve this using triggers?</p>
  
  <p>DATABASE diagram:
  <a href="https://i.stack.imgur.com/HNOhJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HNOhJ.png" alt="Database diagram"></a></p>
  
  <p>I tried this but the <em><code>ON</code></em> gives me an error saying "Unexpected ON":</p>
  
  <pre><code>CREATE TRIGGER cart_trigger
     ON cart_utilizador AFTER UPDATE
     AS
       INSERT INTO cart (id, datas)
         SELECT id_cart, CURDATE()
         FROM cart_utilizador; 
  </code></pre>