Use the following query to get the related category name:
SELECT products.*, productcategories.CategoryName
FROM products
INNER JOIN productcategories
ON products.ProductCategoryID = productcategories.CategoryID
On the detail page, do not replace the WHERE clause. only replace the query up to the WHERE clause.
in the display, make sure to change out the ProductCategoryID binding for the productcategories.CategoryName binding