我会承认,我是一个T-SQL人,不是MySQL人,但我不太明白为什么我收到此错误消息:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DECLARE @UpdatedID VARCHAR(5)' at line 1
这是我的问题:
DECLARE @UpdatedID VARCHAR(5);
SET @UpdatedID = 63;
CREATE TABLE tmp_markers (SELECT * FROM tmp_markers2);
UPDATE tmp_markers
SET Id = Id+1
WHERE Id >= @UpdatedID;
UPDATE tmp_markers
SET Id = @UpdatedID
WHERE Id = MAX(Id);
DELETE from tmp_markers2;
INSERT INTO tmp_markers2
(SELECT * FROM tmp_markers ORDER BY id);
DROP TABLE tmp_markers