CREATE PROCEDURE `spGetBatchRequest` ( IN `P_InstituteId` INTEGER , IN `P_BatchId` INTEGER , IN `P_TeacherId` INTEGER ) BEGIN SELECT `tstudent` . `Id` AS `StudentId` , `ifnull` ( `tuser` . `Name` , ? ) AS `UserName` , `tbatch` . `Id` AS `BatchId` , `tbatch` . `Title` AS `BatchName` , `tstatusmaster` . `Id` AS `StatusId` , `tstatusmaster` . `Title` AS `StatusTitle` FROM `tstudent` INNER JOIN `tassignbatch` ON `tassignbatch` . `StudentId` = `tstudent` . `Id` INNER JOIN `tbatch` ON `tbatch` . `Id` = `tassignbatch` . `BatchId` INNER JOIN `tstatusmaster` ON `tstatusmaster` . `Id` = `tassignbatch` . `StatusId` INNER JOIN `tteacher` ON `tteacher` . `Id` = `tbatch` . `TeacherId` INNER JOIN `tuser` ON `tuser` . `Id` = `tstudent` . `UserId` WHERE `tteacher` . `Id` = `P_TeacherId` AND `tbatch` . `Id` = `P_BatchId` AND `tteacher` . `InstituteId` = `P_InstituteId` AND `tassignbatch` . `StatusId` = ? ; END 