CREATE PROCEDURE `spAlertGetStudyMaterialData` ( IN `P_ContentId` INTEGER , IN `P_CommentId` INTEGER , IN `P_RefferenceCommentId` INTEGER , IN `P_Template` VARCHARACTER (?) , IN `P_BatchId` INTEGER , IN `P_MailSubject` VARCHARACTER (?) , IN `P_UserId` INTEGER , IN `P_RoleTypeId` INTEGER ) BEGIN IF ( `P_CommentId` = ? ) THEN SELECT `SM` . `Id` , `SM` . `Remark` AS `Title` , `B` . `TeacherId` , `SM` . `BatchId` AS `BatchId` , `B` . `Title` AS `BatchName` , `BA` . `StudentId` , `U` . `MobileNo` , `IFNULL` ( `S` . `EmailId` , ? ) AS `EmailId` , REPLACE ( `P_Template` , ? , `B` . `Title` ) AS `MsgText` , `P_MailSubject` AS SUBJECT , ? AS `ReceiverRoleTypeId` , `S` . `Id` AS `ReceiverSourceId` , `U` . `Id` AS `UserId` , `S` . `UserId` AS `ReceiverUserId` , `T` . `InstituteId` AS `InstituteId` FROM `tteachercontentassign` `SM` LEFT JOIN `tbatch` `B` ON `SM` . `BatchId` = `B` . `id` LEFT JOIN `tteacher` `T` ON `B` . `TeacherId` = `T` . `Id` LEFT JOIN `tassignbatch` `BA` ON `B` . `Id` = `BA` . `BatchId` AND `BA` . `StatusId` = ? LEFT JOIN `tstudent` `S` ON `BA` . `StudentId` = `S` . `Id` LEFT 