[英]mysql trigger for before update
hi i have one question for mysql trigger for before update i want when i call sql query for update at that time i want to get old value of column and add with new value 嗨,我有一个问题的mysql触发器为更新之前我想当我在那时调用sql查询更新时,我想获取列的旧值并添加新值
i want to get wallet_balance column value before update and then add new value with old value and then update final value in this table using trigger 我想在更新之前获取wallet_balance列值,然后使用旧值添加新值,然后使用触发器更新此表中的最终值
if i have 1800 and i get 100 then using trigger i want to update 1900 plese help me for this question 如果我有1800,而我得到100,则使用触发器,我想更新1900,请帮助我解决这个问题
Try this: 尝试这个:
DELIMITER $$
CREATE TRIGGER AddwalletValue
Before UPDATE ON admin_wallet FOR EACH ROW
begin
New.wallet_balance = Old.wallet_balance + New.wallet_balance;
END;
$$
DELIMITER ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.