我一直在围绕这个我正在尝试制作的SQL语句,我已经到了墙上可以这么说,如果你能提出任何建议,我做错了什么会有很大的帮助。我在第二个where语句周围得到了错误,但我真的不希望代码的最后一部分能够正常工作。
CREATE TRIGGER UpdateScores AFTER INSERT ON CharSheet FOR EACH ROW begin DECLARE id_exists Boolean; SELECT 1 INTO @id_exists FROM ScoresTable WHERE ScoresTable.PlayerID= NEW.PlayerID; IF @id_exists = 1 THEN UPDATE ScoresTable SET Exp = :New.Exp; WHERE ScoresTable.PlayerID = :NEW.PlayerID; END IF; IF @id_exists = 0 THEN -- I don't expect this part to work yet. INSERT INTO ScoresTable VALUES (:New.PlayerID, :New.Race, :New.Class, :New.Exp); END IF; END; $$
答案 0 :(得分:0)
问题在于这段代码:
THEN
UPDATE
ScoresTable
SET
Exp = :New.Exp;
WHERE
ScoresTable.PlayerID = :NEW.PlayerID;
END IF;
删除set
语句末尾的分号。