MySQL存储过程返回空结果

时间:2013-11-22 15:48:34

标签: mysql sql stored-procedures

我有这个存储过程:

DELIMITER $$

CREATE DEFINER=`thinktosco_com`@`%` PROCEDURE `GetQuestions`(IN languageId CHAR(36), IN userId CHAR(36), IN _limit INT)
BEGIN
    SELECT DISTINCT * FROM `QuestionTranslation` 
    WHERE `LanguageId` = languageId
    AND Phase != 'HISTORY'
    AND `QuestionId` NOT IN (SELECT DISTINCT `QuestionId` FROM `Answer` WHERE `UserId` = userId)
    ORDER BY RAND() LIMIT _limit;
END

运行select语句时,我得到了正确的结果,但是当运行如下所示的存储过程时,我得不到任何结果:

CALL thinktoscore_com_db.GetQuestions('9997f94d-1b90-11e3-92c0-0050568243f2', '9d6a59d9-ee09-41d7-896b-7c9930e324dd', 12);

表QuestionRnslation包含1132行,Answer表包含与userId ='9d6a59d9-ee09-41d7-896b-7c9930e324dd'匹配的484行。谁能指出我在这里做错了什么?

提前致谢。

/Søren

1 个答案:

答案 0 :(得分:0)

在您对Stored-Procedure的调用中,您的参数#1“languageId”看起来非常像参数#2“userId”。

CALL thinktoscore_com_db.GetQuestions(
    '9997f94d-1b90-11e3-92c0-0050568243f2', 
    '9d6a59d9-ee09-41d7-896b-7c9930e324dd', 
    12);

您确定'9997f94d-1b90-11e3-92c0-0050568243f2'是 languageId 吗?