我尝试在更新表之前创建触发器。我希望它在两个特定列更改时有效:status和sale_profit列。如果更新了其中一列,则触发器必须将is_changed列的值设置为1.但是下面的代码给出了如下错误:
错误:
MySQL Error 1064: You have an error in your SQL syntax ... syntax use near at line 7
SQL代码:
CREATE TRIGGER updateIsChanged
BEFORE UPDATE ON manage_product
FOR EACH ROW
BEGIN
IF NEW.`status` <> OLD.`status` || NEW.sale_profit <> OLD.sale_profit
then
SET NEW.is_changed = 1;
END IF;
END
答案 0 :(得分:1)
确定。我通过在代码的开头和结尾添加分隔符解决了我的问题。
更新后的代码:
# from https://httpd.apache.org/docs/2.4/vhosts/examples.html
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>