Categories
Development MySQL

How to create a BEFORE INSERT Trigger

I’m trying to create a BEFORE INSERT trigger and getting errors that I don’t understand.

The MySQL to create the trigger looks like this:

CREATE  TRIGGER `GetPolyLinkID` BEFORE INSERT ON `TableA` 
FOR EACH ROW 
BEGIN
    INSERT INTO TableB () VALUES ();
    NEW.PolyLinkID = last_insert_id();
END

The error I’m getting is

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

Leave a Reply

Your email address will not be published. Required fields are marked *