CREATE PROCEDURE `spGetHomeWork` ( IN `P_BatchId` VARCHARACTER (?) , IN `P_HomeWorkId` INTEGER , IN `P_StudentId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_StartDate` DATE , IN `P_EndDate` DATE ) BEGIN IF ( `P_StudentId` = ? ) THEN SELECT `H` . `id` AS `HomeWorkId` , `H` . `Title` AS `Title` , `tuser` . `Name` AS `TeacherName` , `tbatch` . `Title` AS `BatchName` , `Note` AS `Notes` , CAST ( `Homeworkdatetime` AS CHARACTER ) AS `SubmissionDate` , `IsSendNotificationHomeworkNotSubmit` AS `IsSendNotificationHomeworkNot` , `IsSendSMSHomeworkNotSubmit` AS `IsSendSMSHomeworkNot` FROM `thomework` `H` INNER JOIN `tteacher` ON `H` . `TeacherId` = `tteacher` . `Id` LEFT JOIN `tbatch` ON `tbatch` . `Id` = `H` . `BatchId` INNER JOIN `tuser` ON `tuser` . `Id` = `tteacher` . `UserId` WHERE ( `FIND_IN_SET` ( `BatchId` , REPLACE ( `P_BatchId` , ?, ... ) ) OR `IFNULL` ( `P_BatchId` , ? ) = ? OR `P_BatchId` = ? ) AND ( `H` . `Id` = `P_HomeWorkId` OR `P_HomeWorkId` = ? ) AND ( `P_StartDate` <= DATE ( `H` . `Homeworkdatetime` ) AND DATE ( `H` . `Homeworkdatetime` ) <= `P_EndDate` ) AND ( `H` . `TeacherId` = 