MySQL trigger before insert replace the data with relational table
It may help you in case of AFTER INSERT.

CREATE TRIGGER trigger_name AFTER INSERT ON orders 
    FOR EACH ROW BEGIN IF (SELECT COUNT(*)
              FROM transaction
              WHERE order_id=NEW.order_id) != 0 
    THEN 
        UPDATE transaction SET active = 0 WHERE order_id=NEW.order_id; 
    END IF; 
END