Search product by multiple select category for e-comm project just like Jabong

how to search product by multiple select category in sql server

how to make procedure in sql server.
plz advice me

Use the "in" operator.

select ...
  from ...
 where category in ('Software','Hardware')
;

hi bitsmed,

select ...
from ...
where category in ('Software','Hardware')
it works but when u pass a variable then problem

select ...
from ...
where category in (@ctgrName)

not working

You could handle this in your program where you dynamically generate the query, or you could do a dynamic query on the fly.

Or maybe:

declare @ctgrName varchar(200)=',Hardware,Software,';
select ...
  from ...
 where @ctgrName like '%,'+category+',%'
;

or if you have commas in your category values:

declare @ctgrName varchar(200)='¤Hardware¤Software¤';
select ...
  from ...
 where @ctgrName like '%¤'+category+'¤%'
;

thnx dost

Hello sir
Goodevening.

error when category not select

how to do best idea ???

plz help me sir ?

For this to work, you must always declare @ctgrName.
If you don't assign a value to it, result will be no rows.