我是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);