我想只從外表獲得第一行。從外表獲取頂部1行
我想做下面的代碼,但得到一個錯誤。我無法獲取@rID = PartRequest.Id。
declare @rID int
SELECT
@rID =PartRequest.Id
, Products.Name AS ProductName
, PartRequestPhotos.Id AS PartRequestPhotosId
, PartRequest.IsInsuranceClaimed
FROM PartRequest
INNER JOIN PartRequestStatus ON PartRequest.PartRequestStatusId = PartRequestStatus.Id
INNER JOIN UsersInfo ON PartRequest.UserId = UsersInfo.aspnet_UserId
INNER JOIN Products ON PartRequest.ProductId = Products.Id
LEFT OUTER JOIN PartRequestPhotos ON PartRequest.Id =
(select top 1 Id from PartRequestPhotos where PartRequestId = @rID)
什麼是你的問題?好像你忘了提問。 –
你的代碼有什麼問題? – codingbiz
我無法從PartRequest.Id獲取@rID(@rID = PartRequest.Id) – Eyal