DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`sharingCart_beforeDelete` BEFORE DELETE ON `sharingCart` FOR EACH ROW BEGIN DELETE sc FROM sharingCartDaily sc WHERE sc.dated BETWEEN OLD.started AND OLD.ended AND sc.ownerFk = OLD.workerFk AND sc.substituteFk = OLD.workerSubstitute; END$$ DELIMITER ;