when I try to run this query i get syntax error in last line, this happend after I add the Limit and orderby :
DROP PROCEDURE IF EXISTS `SP_GetFilesInfo`;
CREATE DEFINER = `root`@`localhost` PROCEDURE `SP_GetFilesInfo`(pFileID varchar(20),pFileName varchar(100),pExrtention int,pParentID varchar(20),pSize int,pReferenceID int,pIndex int,pNumOfRec int)
BEGIN
SELECT FileID,
FileName,
FilePath,
Size,
Exrtention,
ParentID,
IsFolder,
ModificationDate,
filesrefrences.ReferenceID,
filesrefrences.RefrenceCount,
filesrefrences.RefrenceKey
from filesinfo LEFT OUTER JOIN filesrefrences ON (filesrefrences.ReferenceID = filesinfo.ReferenceID)
WHERE (pFileID=-99 OR pFileID is NULL OR filesinfo.FileID=pFileID)
AND (pFileName='' OR pFileName is NULL OR filesinfo.FileName LIKE CONCAT('%', pFileName,'%'))
AND (pExrtention=-99 OR pExrtention is NULL OR filesinfo.Exrtention =pExrtention)
AND (pParentID=-99 OR pParentID is NULL OR filesinfo.ParentID=pParentID)
AND (filesinfo.ReferenceID= pReferenceID OR pReferenceID=-99 OR pReferenceID is NULL)
AND (filesinfo.Size=pSize OR pSize=-99 OR pSize is NULL) ORDER BY IsFolder DESC LIMIT 0;
END;
the value of
LIMITshould be greater than 0 ifduration(how many records to display) is not suppliedif you have supplied a duration, the index of the first record on the result is zero, eg
where
0is the index and1is the duration