1
votes

I'm trying to write a very simple trigger for MySQL using phpmyadmin 4.0.8, what I want to do, is after a table called 'upload' is inserted into, I take the username, and id and put it into a second table called 'rating'

This is what I'm trying,

CREATE TRIGGER copy_pid AFTER INSERT on upload FOR EACH ROW BEGIN

INSERT INTO rating (uid,pid) VALUES (NEW.username,NEW.id);

END;

I get an "#1064 - You have an error in..."

1

1 Answers

1
votes

MySQL is interpreting the semi-colon at the end of your INSERT statement as the end of the input. You need to change your delimiter while youe set up your trigger:

delimiter $$
CREATE TRIGGER copy_pid AFTER INSERT on upload FOR EACH ROW 

BEGIN

INSERT INTO rating (uid,pid) VALUES (NEW.username,NEW.id);

END$$
delimiter ;