SQL Query只返回一条记录

时间:2011-03-06 17:36:00

标签: sql-server-2005


我试图运行一个简单的SQL存储过程查询,但只返回1条记录。谁知道问题是什么?

Alter PROCEDURE spGetRecruiterList
AS
BEGIN
    SET NOCOUNT OFF;
    DECLARE @TitleID as int
    set @TitleID = (Select TitleID from tblJobTitle where JobTitle = 'Recruiter')
    Print @TitleID

    Select p.PersonID, p.FirstName, p.MiddleName, p.LastName
    from tblPerson p
    INNER JOIN dbo.tblLinkTitleToPerson tp 
    ON p.PersonID = tp.PersonID 
    WHERE tp.PersonID = @TitleID
    Order By p.LastName
END
GO

1 个答案:

答案 0 :(得分:2)

 WHERE tp.PersonID = @TitleID

应该是

 WHERE tp.TitleID = @TitleID

(可能!)