I have to create a view which gives most fields in Product and a last Boolean (bit) field which tells me whether the product contains a specific accessory. I should have all records in Product appearing once.
You didn't gave us a lot to go on, so I made some assumptions.
CREATE VIEW MyView
CASE WHEN Accessories.Id IS NULL
END as IndHasSpecificAccessory
LEFT OUTER JOIN ProductAccessories ON
Product.Id = ProductAccessories.ProductId
LEFT OUTER JOIN Accessories ON
ProductAccessories.AccessoryId = Accessories.Id AND
Accessories.Name = 'The specific accessory I am interested in'
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2. Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages