0

I want to make trigger which update total_money after every insert in transactions table. I cannot create it because of error: #

1064 - Something is wrong in your syntax near '' in line 3

Here is my trigger creation code:

CREATE TRIGGER transactions_insert AFTER INSERT ON transactions 
    FOR EACH ROW BEGIN
      UPDATE users SET users.total_money = users.total_money + NEW.Price WHERE users.User_ID = NEW.User_id;
    END;

1 Answer 1

1

If you add delimiters it will work, as given below

delimiter //
CREATE TRIGGER transactions_insert AFTER INSERT ON transactions FOR EACH ROW BEGIN UPDATE users SET users.total_money = users.total_money + NEW.Price WHERE users.User_ID = NEW.User_id; END;
//

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.