1
 DELIMITER ||
CREATE TRIGGER `monthly_insert` BEFORE INSERT ON `history_monthly`
FOR EACH ROW
BEGIN
    NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END;
||
DELIMITER ;

And it returns an error:

#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 '.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);
END' at line 4 

It's my first time with triggers and I was doing my best to try to find soultion but I failed ;<

1
  • If this is a BEFORE INSERT trigger, surely there won't be an old row? Commented Feb 9, 2011 at 18:37

1 Answer 1

1

You need to add the word SET in this line:

SET NEW.`uid` = CONCAT(OLD.`year`, OLD.`month`, OLD.`charactersId`);

Also, as the commenter pointed out, there is no OLD value in a BEFORE INSERT trigger.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.