每当我尝试创建以下存储过程时。
CREATE PROCEDURE purchaseItem (IN productID INT, IN quantity INT, IN price DECIMAL(10,2) , IN memID INT)
BEGIN
DECLARE qnty INT DEFAULT 0;
SELECT p_Unit INTO qnty FROM product WHERE p_ID = productID;
IF qnty >= quantity && qnty != 0 THEN
INSERT INTO purchase VALUES (NULL, productID, quantity, price, memID, 0, NULL);
UPDATE product SET p_Unit = (qnty - quantity) WHERE p_ID = productID;
END IF;
END;
我得到错误
#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 '' at line 3
有人可以指出我在哪里做错了。谢谢!