我正在从PhpMyadmin SQL选项卡中运行以下查询:
CREATE TRIGGER trg_bansach ON bill AFTER INSERT AS
BEGIN
UPDATE addbook
SET Quality = Quality - (
SELECT QualitySale
FROM inserted
WHERE book_id = addbook.book_id
)
FROM addbook
JOIN inserted ON addbook.book_id = inserted.book_id
END
但是每次我收到此错误消息时:
#1064-您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以在'FROM addbook'附近使用正确的语法 在哪里addbook.book_id =已插入。book_id END'在第10行
答案 0 :(得分:0)
使用delimiter
DELIMITER //
CREATE TRIGGER trg_bansach ON bill AFTER INSERT AS
BEGIN
UPDATE addbook
SET Quality = Quality - (
SELECT QualitySale
FROM inserted
WHERE book_id = addbook.book_id
)
FROM addbook
JOIN inserted ON addbook.book_id = inserted.book_id;
END
//
DELIMITER ;