我只想从外部表中获取第一行。
我正在尝试执行类似于以下代码的操作,但出现错误。我无法获得 @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)