So what I'm trying to do is, if I add a row in the "angajati"(employees) table, I want the id of said employee to also appear in the "ospatari"(waiters) table. "ospatari" table only has one attribute, the id, and there's a foreign key constraint between ospatari.id and angajati.id.
delimiter //
CREATE TRIGGER InsertOspatar BEFORE INSERT ON angajati
FOR EACH ROW
BEGIN
IF (SELECT rol FROM Inserted) = "Ospatar"
THEN
INSERT INTO ospatari VALUES(Inserted.id);
END IF;
END//
While this code doesn't give me any errors, once I insert a row in "angajati", a row with the same id does NOT appear in "ospatari".
I would really appreciate some help, Thanks!