DELIMITER $$ CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`movementLabel_afterUpdate` AFTER UPDATE ON `vn`.`movementLabel` FOR EACH ROW IF NEW.stem >= (SELECT s.quantity FROM sale s WHERE s.id = NEW.saleFk) THEN UPDATE sale s SET s.isPicked = 1 WHERE s.id = NEW.saleFk; END IF$$ DELIMITER ;