0

I have a trigger like this in MySQL:

DELIMITER $$
CREATE TRIGGER service_before_update BEFORE UPDATE ON service
FOR EACH ROW
BEGIN
    IF NEW.seatCount < (?) THEN
        SIGNAL SQLSTATE '12345';
    END IF;
END$$
DELIMITER ;

instead of (?) I want previous value of "seatCount" is there any easy way or I should use something like this(ServiceNo is a PRI key):

(SELECT seatCount FROM service WHERE serviceNo = NEW.serviceNo LIMIT 1) 

1 Answer 1

1

Yeah, it's super easy. OLD.seatCount should do what you want. http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html has more information.

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.