我試圖運行一個簡單的SQL存儲過程查詢,但只得到1條記錄返回。任何人都知道問題是什麼?SQL查詢只返回一條記錄
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
多少你期待? – 2011-03-06 17:38:12
至少有6條記錄 – Csharp 2011-03-06 17:40:25
我認爲這很正常,因爲PersonID是主鍵。 'WHERE tp.PersonID = @ TitleID'將只返回一個結果。 – malinois 2011-03-06 17:45:10