title: MySQL Trigger on 2 tables with
body: <p>I have 2 tables</p>
  
  <p>FIRST</p>
  
  <pre><code> ps_product (id_product, price)
  </code></pre>
  
  <p>SECOND</p>
  
  <pre><code> ps_product_price (id_product, price, price_tax)
  </code></pre>
  
  <p>Now what I trying to do is to SET TRIGGER:</p>
  
  <pre><code>DELIMITER $$
  CREATE TRIGGER `after_ps_product_price_update`  
      BEFORE UPDATE ON `ps_product_price` 
        FOR EACH ROW  
      BEGIN
        UPDATE ps_product 
         SET price = NEW.price_tax -(NEW.price_tax * 0.1666666666666666666)
         WHERE id_product = NEW.id_product;  
      END
  </code></pre>
  
  <p>When ps_rpoduct_price TABLE, COLUMN(price_tax) is updated then update TABLE ps_product, COLUMN (price)</p>
  
  <p>And that works fine but when I try do do this same other way around:</p>
  
  <pre><code>DELIMITER $$
  CREATE TRIGGER `after_ps_product_update`  
      AFTER UPDATE ON `ps_product` 
        FOR EACH ROW  
      BEGIN
        UPDATE ps_product_price
         SET price_tax = (NEW.price * 1.2)
         WHERE id_product = NEW.id_product;  
      END
  </code></pre>
  
  <p>Then I get an error:</p>
  
  <blockquote>
    <p>Can't update table 'ps_rpoduct' in stored function/trigger because it is already used by statement which invoked this stored function/trigger</p>
  </blockquote>