DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`itemShelvingSale_afterInsert` AFTER INSERT ON `itemShelvingSale` FOR EACH ROW BEGIN UPDATE sale s JOIN operator o ON o.workerFk = account.myUser_getId() SET isPicked = IF(o.isOnReservationMode, isPicked, TRUE) WHERE id = NEW.saleFk; END$$ DELIMITER ;