0

I'm trying to create a trigger that monitor changes on a table and then insert those change to another table as follows

CREATE TRIGGER userChangePasswd
BEFORE UPDATE ON originalTable
FOR EACH ROW
BEGIN
INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable
END

mysql keeps showing the following error

ERROR 1064 (42000): 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 'INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM ' originalTable at line 5

the following statement works very file with a where clause criteria

INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable 

what's wrong with the insertion statement within the trigger

1
  • are you using a version higher than 5.0.10 ? Commented Aug 18, 2009 at 13:56

1 Answer 1

1
CREATE TRIGGER `orgTbl_before_upd_tr` BEFORE UPDATE ON `orgTbl`
FOR EACH ROW
BEGIN
  INSERT INTO newTbl (field1, field2) VALUES (old.field1, old.field2);
END;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.