Reputation: 10694
I am working on following query
Select p.* from Product Inner Join Product_Category_Maping pcm on P.Id=Pcm.ProductId
where
dbo.[CHECKCHARINDEX](@Keyword,p.Name+' '+
@CatName=(Select C.Name from category C where C.Id=Pcm.CategoryId))=1
I want to pass both product and category name to function for some check . How can I do it
Upvotes: 0
Views: 76
Reputation: 156948
I suggest you to move the select
to a join
. Makes it easier and clearer.
select p.*
from product p
join product_category_maping pcm
on p.id = pcm.productid
join category c
on c.id = pcm.categoryid
where dbo.[checkcharindex](@keyword, p.name + ' ' + c.name) = 1
Also, I think you forgot to give the product
table the alias p
.
Upvotes: 4