如何修复这个IF-ELSE-THEN语句在MySQL触发器 [英] How to fix this IF-ELSE-THEN statement in a MySQL trigger

查看:622
本文介绍了如何修复这个IF-ELSE-THEN语句在MySQL触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何修复此MySQL触发器?





CREATE TRIGGER Transaction_insert BEFORE INSERT ON Transaction
FOR EACH ROW
IF Account.CreditBalance + NEW.Amount < Account.CreditLimit WHERE Number = NEW.AccountNumber THEN
UPDATE Account SET CreditBalance = CreditBalance + NEW.Amount where Number = NEW.AccountNumber;
ELSE
SET NEW.Valid = 0
END IF; 

我从phpMyAdmin收到此错误消息。

I get this error message from phpMyAdmin.

推荐答案

这是If语句的正确语法。

This is the proper syntax for the If statement.

IF search_condition THEN statement_list
    [ELSEIF search_condition THEN statement_list] ...
    [ELSE statement_list]
END IF

您不能在该地点拥有 Where 子句!

You can't have the Where clause in that spot!

这篇关于如何修复这个IF-ELSE-THEN语句在MySQL触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆