-3

Code in MySQL:

create trigger insert_adm
after
  insert on table_student for each row BEGIN
INSERT INTO
  Admission(ID_Student, registration_date)
VALUES
  (new.ID_Student, CURDATE()) END;

Error output:

Error Code: 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 'END' at line 7.

I have no clue what to do Whats wrong in this mysql code?

Ergest Basha
  • 7,870
  • 4
  • 8
  • 28

1 Answers1

0

Try END$$ instead of END. Some explanation on delimiters here: Delimiters in MySQL

Final code:

CREATE TRIGGER insert_adm
AFTER INSERT ON table_student
FOR EACH ROW
BEGIN
    INSERT INTO Admission (ID_Student, registration_date)
    VALUES (new.ID_Student, CURDATE());
END$$
Elanaris
  • 56
  • 1
  • 5
  • Delimiters and begin..end are not required especially for a single statement in a trigger BUT the single statement does require a terminator. – P.Salmon Jan 04 '23 at 15:22