I'm trying to create a simple Before Insert MySQL Trigger, to check if any duplicates exists in the table. But I get syntax errors in the lines with the (*). What's wrong ?
delimiter ;
(*) CREATE TRIGGER `BookLanguages_BeforeInsertTrigger`
BEFORE INSERT ON `BookLanguages`
FOR EACH ROW
BEGIN
IF (exists(select * from Languages bl where bl.BookID = new.BookID and bl.LanguageID = new.LanguageID)) THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'An error occurred';
END IF;
(*) END;
I'm using the Community server v5.5.21