DELIMITER $$ CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`travel_recalc`(vSelf INT) proc: BEGIN /** * Updates the number of entries assigned to the travel. * * @param vSelf The travel id */ UPDATE travel SET totalEntries = ( SELECT COUNT(id) FROM entry WHERE travelFk = vSelf ) WHERE id = vSelf; END$$ DELIMITER ;