Why can't you just put it all in one statement? Like this:
SELECT ca.Name AS AgeGroup, ca.Category
FROM Category AS ca INNER JOIN
Category AS parentca ON ca.ParentCategoryID = parentca.CategoryID INNER JOIN
ProductCategory AS prodca ON ca.CategoryID = prodca.CategoryID
WHERE (parentca.Name = N'Books By Age' or parentca.Name=N'Kids Books') AND (prodca.ProductID = 30891)
Or am I missing something else?
Hope this helps!
↧