title: How to calculate two variables inside mysql trigger?
body: <p>I have a trigger and inside of him I have declared two variables: quantity and price. Quantity is type INT and price is type DECIMAL(10,2). Value of those variables are set by the SELECT query. And that works nicely. Now I want to multiply those two variables so I can get total amount.</p>
  
  <p>total_amount = quantity * price</p>
  
  <p>Simplified code (doesn't work it s here just to better describe my problem):</p>
  
  <pre><code>DROP TRIGGER calculate;
  DELIMITER $$
  CREATE TRIGGER calculate 
      AFTER INSERT ON order_table
      FOR EACH ROW 
          BEGIN
          DECLARE quantity INT;
          DECLARE price INT;
  
          SELECT quantity, price INTO @quantity, @price FROM product;
  
          INSERT INTO order_details SET total_amount = @quantity * @price;
  
          END$$
  DELIMITER ;
  </code></pre>
  
  <p>With this code I get null as result.
  I am using MySQL/MariaDB.</p>