DELIMITER //
CREATE PROCEDURE compare (x INT, y INT) RETURNS INT
BEGIN
DECLARE test INT;
IF x > y
THEN SET test = 1;
ELSEIF y > x
THEN SET test = -1;
ELSE SET test = 0;
END IF;
RETURN test;
END
//
任何人都可以在这里看到错误吗? PhpMyAdmin说
#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 'INT BEGIN DECLARE test INT; IF x > y THEN SET test = 1; ELSEIF y >' at line 1
答案 0 :(得分:4)
你必须CREATE FUNCTION
,因为程序不能返回任何东西,只有函数可以。