gpt4 book ai didi

mysql - MySQL 中的存储过程出现问题

转载 作者:行者123 更新时间:2023-11-29 22:41:11 24 4
gpt4 key购买 nike

我想知道使用 XAMPP 创建此存储过程时出了什么问题。

use PizzaShop;

delimiter /

CREATE PROCEDURE `updateDelivery` (IN @driver INT(3), IN @orderNum INT(5))
BEGIN
INSERT INTO `orders`(`deliveredBy`,`complete`) VALUES(@driver ,TRUE) WHERE orders.Order_No = @orderNum;
end;
/

delimiter ;

我收到的错误是

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 '@driver INT(3), IN @orderNum INT(5)) BEGIN INSERT INTO order(deliveredBy,`' at line 1

最佳答案

带有 where 子句的 insert 语句的语法无效并且没有多大意义。 where 子句的存在表明您可能想要做的是更新?

use PizzaShop;

delimiter /

CREATE PROCEDURE `updateDelivery` (IN driver INT(3), IN orderNum INT(5))
BEGIN
UPDATE orders
SET deliveredBy = driver, completed = TRUE
WHERE orders.Order_No = orderNum;
END /

delimiter ;

关于mysql - MySQL 中的存储过程出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29342571/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com