このクエリを実行しようとすると、最後の行で構文エラーが発生します。これは、Limitと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;