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 s.isPicked = IF(o.isOnReservationMode, s.isPicked, TRUE) WHERE id = NEW.saleFk; END$$ DELIMITER ;