I'm using Aurora Serverless MySQL 5.6 to create the following trigger which will update one table when data is inserted into another table but am receiving syntax errors, specifically around the Delimiter keyword.
DELIMITER $$
CREATE TRIGGER Create_Media_Like_Trigger AFTER INSERT ON MediaLike
FOR EACH ROW
BEGIN
IF NEW.likeType = 'LIKE' THEN
UPDATE Media
SET Media.numLikes = Media.numLikes + 1
WHERE Media.mediaId = NEW.mediaId;
ELSEIF NEW.likeType = 'DISLIKE' THEN
UPDATE Media
SET Media.numLikes = Media.numLikes - 1
WHERE Media.mediaId = NEW.mediaId;
ENDIF;
END $$
DELIMITER ;
Like I said above, I am receiving syntax errors near DELIMITER, is this issue AWS specific and how can I fix it?
UPDATE with error messages:
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 'DELIMITER $$ CREATE TRIGGER Create_Media_Like_Trigger
AFTER INSERT ON MediaLike ' at line 1
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 'ELSEIF NEW.likeType = 'DISLIKE' THEN UPDATE Media SET
Media.numLikes = Media.num' at line 1
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 'END $$' at line 1