mysql触发器if then,如何修复这个IF-ELSE-THEN语句在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;

I get this error message from phpMyAdmin.

解决方案

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

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

你可能感兴趣的:(mysql触发器if,then)