1
CREATE TRIGGER event_house_dealed AFTER UPDATE ON house FOR EACH ROW 
BEGIN
DECLARE finished INT;
IF NEW.isdeal = 1 THEN
    SET finished = 1;
END IF;
END;

The MySQL server keep saying

SQL Error (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NEW.isdeal = 1 THEN SET finished = 1' at line 1

Thanks.

1 Answer 1

2

You need to change delimiter before defining trigger

DELIMITER ||
CREATE TRIGGER event_house_dealed AFTER UPDATE ON house FOR EACH ROW 
BEGIN
DECLARE finished INT;
IF NEW.isdeal = 1 THEN
    SET finished = 1;
END IF;
END||

Then of course change the delimiter back to ;

DELIMITER ;

Same goes for declaring functions and stored procedures

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.