区切り文字を;
以外に設定する必要があります
DELIMITER |
CREATE TRIGGER blockuserundo BEFORE DELETE ON user_blocked
FOR EACH ROW BEGIN
UPDATE members SET ty_status = '1' WHERE user_id = OLD.block_user_id ;
END;
|
DELIMITER ;
以下のコードは期待どおりに機能します:
DROP TABLE IF EXISTS user_blocked;
CREATE TABLE user_blocked
(
block_user_id INT
);
DROP TABLE IF EXISTS members;
CREATE TABLE members
(
user_id INT,
ty_status CHAR(1)
);
INSERT user_blocked
VALUES (1),(2),(3),(4),(5);
INSERT members
VALUES (1, '0'),(2, '0'),(3, '0'),(8, '0'),(9, '1');
DELIMITER |
CREATE TRIGGER blockuserundo BEFORE DELETE ON user_blocked
FOR EACH ROW BEGIN
UPDATE members SET ty_status = '1' WHERE user_id = OLD.block_user_id ;
END;
|
DELIMITER ;
SELECT * FROM members;
DELETE FROM user_blocked WHERE block_user_id IN(1,2);
SELECT * FROM members;