I have a table named user. This table has a foreign key to a department table. One user can be associated with one department. Before deleting a department, I would like to
I haven't tested it, but based on the documentation, this looks about right:
CREATE TRIGGER update_user_before_delete BEFORE DELETE ON department
FOR EACH ROW BEGIN
UPDATE user SET department = 1 WHERE department = OLD.department;
END;