0

当我尝试运行此查询时,我在最后一行出现语法错误,这发生在我添加Limitorderby之后:

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;
4

1 回答 1

2

如果(要显示的记录数)未提供,则 的值LIMIT应大于 0duration

ORDER BY IsFolder DESC 
LIMIT 1;

如果您提供了duration,则结果中第一条记录的索引为零,例如

ORDER BY IsFolder DESC 
LIMIT 0, 1;

哪里0索引1持续时间

于 2013-01-26T08:47:05.120 回答