MYSQL更新触发器不更新列

时间:2018-04-13 18:34:33

标签: mysql triggers

我有这个触发器

DELIMITER ;

 DELIMITER $$
CREATE TRIGGER when_auction_ends
    AFTER UPDATE ON Auctions
    FOR EACH ROW 
BEGIN

    SELECT A.vin, A.status, A.winner, A.minprice, B.amount, B.buyer INTO @vin, @stat, @winner, @minprice, @amount, @buyer

    FROM Auctions A, Bids B WHERE A.status = 'Inactive' AND A.winner = null AND A.vin = B.vin AND B.amount = (SELECT MAX(amount) FROM Bids B WHERE B.vin = A.vin AS 




    IF @amount < @minprice THEN

    UPDATE Auctions
    SET A.winner = 'NONE'
    WHERE A.vin = B.vin;

    ELSEIF @amount >= @minprice THEN

    UPDATE Auctions
    SET A.winner = B.buyer
    WHERE A.vin = B.vin;



    END IF ;


END$$
DELIMITER ;

但是当它激活时,值不会更新。我想它是因为mysql不知道A.winner在“SET A.winner”中是什么。我尝试在线查看如何使用OLD和NEW,但没有任何运气。

0 个答案:

没有答案