I'm trying to create a trigger to insert into a new table using values from two different tables (I'm using MySQL 5.5.27).
I get a syntax error when I try this but cannot see where the error is.
DECLARE _Token VARCHAR(255);
SELECT token INTO _Token FROM appusers ON username = NEW.username;
INSERT INTO queue (token, message) VALUES (_Token, NEW.milestone);
My assumption is that it doesn't like the DECLARE because when I use the following I get message that _Token is an undeclared variable.
SELECT token INTO _Token FROM appusers ON username = NEW.username;
INSERT INTO queue (token, message) VALUES (_Token, NEW.milestone);