我只是想为我的phpmyadmin创建一个触发器。基本上,预期的功能是每当我更新财务表的信用列时,余额列将自动更新每行。
我的节目是:
CREATE TRIGGER UPDATE_BALANCE AFTER UPDATE financeofstudents
FOR EACH ROW
BEGIN
IF financeofstudents.credit > 0
AND
financeofstudents.credit <= financeofstudents.debit
THEN
UPDATE financeofstudents SET financeofstudents.balance = financeofstudents.debit- financeofstudents.credit;
END IF;
END
但它给了我这个错误:
Error
SQL query:
CREATE TRIGGER UPDATE_BALANCE AFTER UPDATE financeofstudents
FOR EACH ROW
BEGIN
IF financeofstudents.credit > 0
AND
financeofstudents.credit <= financeofstudents.debit
THEN
UPDATE financeofstudents SET financeofstudents.balance = financeofstudents.debit-financeofstudents.credit
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'financeofstudents
FOR EACH ROW
BEGIN
IF financeofstudents.credit > 0
AND
f' at line 1
我不知道问题出在哪里。专家们,请帮助我。
答案 0 :(得分:0)
错误消息是一个有用的提示。它表示 ..要在 foreach($_POST['commit_date'] as $commitdate) {
foreach($_POST['unit'] as $units) {
echo $units .= $commitdate . "<br/>";
}
}
附近使用正确的语法。
在您的情况下,您需要在表名前加上'some text from your query starting with the first thing it didn't understand'
一词。
ON
如果您发现MySQL错误消息难以解释,那么您就是正确的。