I had to restore a table from a backed-up version of that table. Then I went to recreate the triggers. I can’t get one re-created. I’ve looked at some examples of how this sort of trigger should look nothing here glares at me. I copied it from the code showed in phpmyadmin when i clicked “change” on the old trigger to save it. I thought that would be foolproof!
1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 5
CREATE TRIGGER `trig_parts_price_AfterUpdate` AFTER UPDATE ON `parts`
FOR EACH ROW BEGIN
IF (NEW.cost <> OLD.cost || NEW.price <> OLD.price || NEW.QtyInStock <> OLD.QtyInStock) THEN
INSERT INTO `inv_hist_simple` (sku, cost, price, QtyInStock, change_date)
VALUES(OLD.sku_m, NEW.cost, NEW.price, NEW.QtyInStock, NOW());
END IF;
END;
Put this line above your code:
and change the last line of your code to
Then add this line at the end:
Otherwise the
;tells the server, that the code for the trigger finishes after your insert statement, which is causing the syntax error.So it basically should look like this: