mysql存储过程根据另一个表更新数据

时间:2013-11-16 21:28:30

标签: mysql

我正在尝试运行一个存储过程,允许我根据条形码更新另一个表的shelfprice从一个表更新shelfprice。但我是mysql的新手,无法解决问题。使用下面的代码,我不断收到错误代码1172.我将如何实现这一目标?

DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `Test_scheduler`()
BEGIN
DECLARE CodeOld INT DEFAULT 0; DECLARE CodeNew INT DEFAULT 0;
DECLARE NewPrice DECIMAL(10,2) DEFAULT 0.00; DECLARE OldPrice DECIMAL(10,2) DEFAULT 0.00;
SELECT LiquorCode INTO CodeOld FROM liquor_liquor;
SELECT LiquorCode INTO CodeNew FROM liquor_update;
SELECT ShelfPrice INTO NewPrice FROM liquor_update;
SELECT ShelfPrice INTO OldPrice FROM liquor_liquor;

WHILE CodeOld = CodeNew DO
SET OldPrice = NewPrice;
END WHILE;



END

0 个答案:

没有答案