当我尝试运行此查询时,我在最后一行收到语法错误,这是在我添加限制和 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;
答案 0 :(得分:2)
如果未提供LIMIT
(要显示的记录数),则duration
的值应大于0
ORDER BY IsFolder DESC
LIMIT 1;
如果您提供了持续时间,则结果中第一条记录的索引为零,例如
ORDER BY IsFolder DESC
LIMIT 0, 1;
其中0
是索引而1
是持续时间