首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MySQL存储过程错误

问MySQL存储过程错误
EN

Stack Overflow用户
提问于 2014-03-04 02:39:42
回答 1查看 53关注 0票数 1

我得到了这个错误

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'lstart, lend; END IF; ELSE IF lstart = -1 THEN select count(*) a' at line 8"

在服务器上创建这个存储过程,但在我的本地主机phpmyadmin中创建时没有任何错误?

代码语言:javascript
复制
DELIMITER
create procedure getallmedia(IN cat int(2), IN asc_desc varchar(5), IN lstart int(11), IN lend int(11))
BEGIN
IF cat = -1 THEN
    IF asc_desc = 'asc' THEN
        IF lstart = -1 THEN
            select count(*) as result from bc_media where id <> -1;
        ELSE
            select * from bc_media where id <> -1 limit lstart, lend;
        END IF;
    ELSE
        IF lstart = -1 THEN
            select count(*) as result from bc_media where category = cat;
        ELSE
            select * from bc_media where category = cat order by id desc limit lstart, lend;
        END IF;
    END IF;
ELSE
    IF asc_desc = 'asc' THEN
        IF lstart = -1 THEN
            select count(*) as result from bc_media where category = cat;
        ELSE
            select * from bc_media where category = cat limit lstart, lend;
        END IF;
    ELSE
        IF lstart = -1 THEN
            select count(*) as result from bc_media where category = cat;
        ELSE
            select * from bc_media where category = cat order by id desc limit lstart, lend;
        END IF;
    END IF;
END IF;
END
DELIMITER ;

请帮帮我:

EN

回答 1

Stack Overflow用户

发布于 2014-03-08 01:09:24

我不确定,但是,在first DELIMITER尝试将$$

在最后一个结束后,把$$

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22154616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档