CREATE PROCEDURE `spAlertGetFeeSetup` ( IN `P_Template` VARCHARACTER (?) , IN `P_MailSubject` VARCHARACTER (?) , IN `P_FeeId` INTEGER , IN `P_BatchId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_StudentId` INTEGER ) BEGIN SELECT `f` . `Id` , `f` . `TeacherId` , `f` . `StudentId` , `U` . `MobileNo` , `T` . `UserId` AS `UserId` , `IFNULL` ( `S` . `EmailId` , ? ) AS `EmailId` , REPLACE ( REPLACE ( REPLACE ( `P_Template` , ? , `B` . `Title` ) , ? , SQL_TSI_MONTH ( NOW ( ) ) ) , ? , `f` . `FeeAmount` ) AS `MsgText` , `P_MailSubject` AS SUBJECT , ? AS `ReceiverRoleTypeId` , `S` . `Id` AS `ReceiverSourceId` , `S` . `UserId` AS `ReceiverUserId` , `T` . `InstituteId` AS `InstituteId` , `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` FROM `tfeesetup` `f` LEFT JOIN `tbatch` `B` ON `f` . `BatchId` = `B` . `Id` LEFT JOIN `tteacher` `T` ON `T` . `Id` = `B` . `TeacherId` LEFT JOIN `tstudent` `S` ON `f` . `StudentId` = `S` . `Id` LEFT JOIN `tuser` `U` ON `S` . `UserId` = `U` . `Id` LEFT JOIN `tuser` `U1` ON `T` . `UserId` = `U1` . `Id` WHERE `f` . `BatchId` = `P_BatchId` AND `f` . `Id` = `P_FeeId` AND 