I m trying to search several tables at once for a search term. My query is:
SELECT item.ItemID
FROM Inventory.Item item
JOIN Inventory.Category catR // each item can be in several categories
ON catR.ItemID = item.ItemID
JOIN Category.Category cat
ON cat.CategoryID = catR.CategoryID
JOIN Inventory.Brand bran
ON bran.BrandID = item.BrandID
WHERE
item.Description LIKE % + @term + %
OR
item.Description LIKE % + @term
OR
item.Description LIKE @term + %
OR
item.Description = @term
OR
cat.CategoryName LIKE % + @term + %
//same pattern as item.Description used to search CategoryName
//...
OR
bran.BrandName LIKE % + @term + %
//same pattern as item.Description used to search BrandName
//...
But the results are not as expected. I have about 50 items in the category "Casement" but when term == "Casement" only items that have "Casement" in their item.Description will be returned.
Am I doing something wrong? Should I do this a better way?