CREATE PROCEDURE `spGetAssignBatch` ( IN `P_BatchId` INTEGER ) BEGIN SELECT `tstudent` . `id` AS `StudentId` , `IFNULL` ( `tuser` . `Name` , ? ) AS `UserName` FROM `tassignbatch` INNER JOIN `tstudent` ON `tstudent` . `id` = `tassignbatch` . `studentid` INNER JOIN `tuser` ON `tuser` . `id` = `tstudent` . `UserId` WHERE `tassignbatch` . `BatchId` = `P_BatchId` AND `tassignbatch` . `StatusId` = ? ; END 