DELIMITER $$

CREATE FUNCTION leave_request_last_comment
(
  id INT
)
RETURNS VARCHAR(255)
DETERMINISTIC
READS SQL DATA
BEGIN
  RETURN (select lrc.comments from ohrm_leave_request_comment as lrc where lrc.leave_request_id = id order by lrc.id desc limit 1);
END;$$


CREATE FUNCTION leave_last_comment
(
  id INT
)
RETURNS VARCHAR(255)
DETERMINISTIC
READS SQL DATA
BEGIN
  RETURN (select lc.comments from ohrm_leave_comment as lc where lc.leave_id = id order by lc.id desc limit 1);
END;$$

DELIMITER ;