CREATE TRIGGER `db_name`.`trigger_name` BEFORE DELETE ON `db_name`.`table1_name`
FOR EACH ROW
BEGIN
INSERT INTO `db_name`.`table2_name`(table2_id,`comment`,record_created_date)
VALUES (OLD.id, OLD.`comment`, NOW());
END
The syntax error happens at "OLD.comment
" because comment is a reserved word in MySql and it's after OLD, the query above doesn't work even with backtick ("`").
Of course, the easiest solution is to change the column name. But, it's not an option in my case. Please help if you know the correct syntax. Thanks.