CREATE PROCEDURE `spGetTimeTableNew` ( IN `P_BatchId` INTEGER , IN `P_StudentId` INTEGER , IN `P_InstituteId` INTEGER , IN `P_FromDate` DATE , IN `P_ToDate` DATE ) BEGIN IF ( `P_StudentId` > ? ) THEN SELECT `TT` . `Id` AS `TimeTableId` , CAST ( `TT` . `FromTime` AS CHARACTER ) AS `FromTime` , CAST ( `TT` . `ToTime` AS CHARACTER ) AS `ToTime` , CAST ( `ifnull` ( `TT` . `FromDate` , ? ) AS CHARACTER ) AS `FromDate` , `B` . `Id` AS `BatchId` , `B` . `Title` AS `BatchName` , `TT` . `Subject` , `ifnull` ( `TT` . `Title` , ? ) AS `Title` , `TT` . `IsSession` , `ifnull` ( `TT` . `AnouncementMessage` , ? ) AS `AnouncementMessage` FROM `ttimetable` `TT` INNER JOIN `tbatch` `B` ON `B` . `Id` = `TT` . `BatchId` INNER JOIN `tassignbatch` `AB` ON `AB` . `BatchId` = `B` . `Id` INNER JOIN `tteacher` `T` ON `T` . `Id` = `B` . `TeacherId` LEFT JOIN `tonlinelecture` `OL` ON `OL` . `TimeTableId` = `TT` . `Id` WHERE ( `TT` . `BatchId` = `P_BatchId` OR `P_BatchId` = ? ) AND ( `AB` . `StudentId` = `P_StudentId` ) AND ( ( `T` . `InstituteId` = `P_InstituteId` AND `TT` . `Day` = `DayName` ( NOW ( ) 