Mysql 存储过程在添加一个参数后失败

Mysql 存储过程在添加一个参数后失败,mysql,stored-procedures,Mysql,Stored Procedures,这是我的存储过程 CREATE DEFINER=`root`@`localhost` PROCEDURE `getGameIdByPlayerAndDate`(out id integer) BEGIN -- DECLARE myCursor CURSOR FOR select game from `playerstatistic`, `game` where `playerstatistic`.`game`=`game`.`id` and `date`="2014-03-26"

这是我的存储过程

CREATE DEFINER=`root`@`localhost` PROCEDURE `getGameIdByPlayerAndDate`(out id integer)
BEGIN
-- DECLARE myCursor CURSOR FOR 
select game
from `playerstatistic`, `game`
where `playerstatistic`.`game`=`game`.`id`
    and `date`="2014-03-26"
    and `PlayerName`="Kenneth Faried";

    -- open myCursor;
    -- FETCH myCursor INTO id;  


    -- set id=0;


    -- SELECT id;  
    -- SET id=2;  
    -- SELECT id;  
END
我想传递玩家姓名和日期,程序返回游戏id。但是现在为了解决问题,我硬编码了玩家姓名和日期

我调用程序,它选择正确的数据。

然后我将
playerName
参数添加到过程中,并将一个伪参数添加到call语句中。存储过程现在不选择任何内容


我写错什么了吗?如何使代码工作?

必须指定作为参数传递的值:

首先,更改名称以避免重复名称:

CREATE PROCEDURE `getGameIdByPlayerAndDate`(IN p_playerName varchar(40),out id integer)
现在将此参数指定给PlayerName字段

`PlayerName` = p_playerName;

我根本没有使用这个参数。参数重要吗?我将参数的名称从playerName更改为testName,然后该过程像以前一样工作。似乎该参数以某种方式覆盖了表的列。我想知道为什么。之所以会这样,是因为MySQL不区分表字段名的变量名。除了更改名称之外,还有另一个解决方案,就是完全限定列名,即。
和playerstatistic.PlayerName=PlayerName