嗨,我在 MySQL 中执行以下代码时遇到错误:
BEGIN
DECLARE right_most_sibling INTEGER;
SET right_most_sibling
= (SELECT rgt
FROM Personnel
WHERE emp = 'Albert');
UPDATE Personnel
SET lft = CASE WHEN lft > right_most_sibling
THEN lft + 2
ELSE lft END,
rgt = CASE WHEN rgt >= right_most_sibling
THEN rgt + 2
ELSE rgt END
WHERE rgt >= right_most_sibling;
INSERT INTO Personnel (emp, lft, rgt)
VALUES ('Bert', right_most_sibling,
(right_most_sibling + 1))
END;
我收到以下错误:
#1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的“DECLARE right_most_sibling INTEGER”附近使用正确的语法
任何想法,我该如何解决?
我正在关注本教程