Hopefully this is something simple but what i am trying to do is only pull back 1 row for each product in the CartContents table. The problem i have is some products have multiple images so and these are being returned if there is more than 1 image linked to a product.
This is what i created however it still pulls back multiple rows for each product.
SELECT DISTINCT (pri.FileName), p.Title, tc.Quantity, tc.FK_ProductID
FROM [Ordering].[CartContents] tc
INNER JOIN [Ordering].[Products] p ON p.ProductID = tc.FK_ProductID
INNER JOIN [Ordering].[ProductImages] pri on pri.FK_ProductID = p.ProductID
WHERE FK_UserID = @FK_UserID
Thanks
“in” would get rid of the problem, assuming you didn’t have the filename:
With the filename, you have to choose one arbitarily: