1

I want to make a trigger to a certain table that makes it so that when I insert data into that table, two other tables are updated. I am trying to do something like this, on the trigger section of phpMyAdmin:

INSERT INTO db.tableOne (id, name, country) VALUES (NEW.id, NEW.name, NEW.country);

INSERT INTO db.tableTwo (id, colour, price) VALUES (NEW.id, NEW.colour, NEW.price);

It gives me a syntax error.

I tried creating 2 different triggers for the same action on that table but it says that I can't have 2 triggers for the same action. Any help is deeply appreciated!

2
  • Ok, solved. For anyone who has the same problem, it's quite easy actually: just put a "BEGIN" statement before the "INSERT" statements, and a "END" statement after. Commented Jan 24, 2013 at 22:43
  • 1
    You should select the 'Solve/Answer your own question' option and put your comment in there. Thanks for the update! Commented Jan 25, 2013 at 20:40

1 Answer 1

3

Ok, solved. For anyone who has the same problem, it's quite easy actually: just put a "BEGIN" statement before the "INSERT" statements, and a "END" statement after.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.