在存储过程中运行的MySQL查询的输出不正确

时间:2018-10-07 22:39:13

标签: mysql stored-procedures

我是MySQL的新手。运行此查询时,我得到正确的输出:

select
        m.chirpid as 'Chirp Id',
        c.text as 'Chirp Text',
        c._created as 'Chirp Date'
from mentions m 
join chirps c on c.id = m.chirpid
where m.userid = 1;

但是当我将相同的查询放入存储过程中并调用它时,我得到了错误的输出。它返回用户提到的= 2而不是1的数据。我缺少什么?或者我该如何调试?

delimiter //

CREATE PROCEDURE spUserMentions
(usermentioned int)
BEGIN
    select
            m.chirpid as 'Chirp Id',
            c.text as 'Chirp Text',
            c._created as 'Chirp Date'
    from mentions m 
    join chirps c on c.id = m.chirpid
    where m.userid = usermentioned;
END//

delimiter ;



call spUserMentions(1);

0 个答案:

没有答案