CREATE PROCEDURE `spGetAssignLinkList` ( IN `P_BatchId` INTEGER , IN `P_TeacherId` INTEGER , IN `P_FolderName` VARCHARACTER (?) ) BEGIN DECLARE `P_ContentPath` VARCHARACTER (?) ; IF ( `P_Foldername` IS NULL ) THEN SET `P_ContentPath` = ( SELECT `contentpath` FROM `tteachercontent` WHERE `id` IN ( SELECT DISTINCTROW ( `teachercontentId` ) FROM `tteachercontentassign` WHERE `Batchid` = `P_BatchId` ) ) ; ELSE SET `P_ContentPath` = ( SELECT REPLACE ( `CONCAT` ( `contentpath` , ? , `P_FolderName` , ? ) , ?, ... ) FROM `tteachercontent` WHERE `id` IN ( SELECT DISTINCTROW ( `teachercontentId` ) FROM `tteachercontentassign` WHERE `Batchid` = `P_BatchId` ) ) ; END IF ; SELECT `Id` , `ContentLink` AS `Path` , `ContentTitle` AS `Title` , `CreatedDatetime` AS `CreateTime` FROM `tteachercontent` WHERE ( `Contentpath` IN ( SELECT `P_ContentPath` ) OR `Contentpath` LIKE ( SELECT `P_ContentPath` ) ) AND `contentlink` IS NOT NULL AND `TeacherId` = `P_TeacherId` ; END 