嗨,我有以下存储过程,它返回多个照片名称。我只想返回第一行。我尝试了 TOP 1,但我确定我犯了一些语法错误。请帮忙
CREATE PROCEDURE getProductsBySubCategoryName
@SubCategoryName nvarchar(50)
AS
BEGIN
SELECT Products.productName, subCategory.subcategoryName, Photos.photoName
FROM subCategory INNER JOIN Products ON
subCategory.subcategory_id = Products.subcategory_id
INNER JOIN Photos ON
Products.product_id = Photos.product_id
WHERE (subcategoryName = @SubCategoryName)
END
还有一个问题。当 photoName 为 null 或为 null photo 选择指定记录时如何选择 -</p>