Wednesday, 28 August 2013

How to bring out proper search data for the user asp.net(c#)

How to bring out proper search data for the user asp.net(c#)

Well my scenario is like this i need to show certain apps to a user by
matching his/her country , state , Age group and gender.
For this i have a DB and an admin panel where i enter a set of apps with
fields like what country you want to target , gender you want to target ,
age group you want to target etc. [However these options can be left
blank]
Right now i have made a query that brings out a list based on all provided
parameters which makes the search very specific what should i do to solve
this problem how can i make this scenario better and show results when the
below query is empty. [Don't have much data to work with right now]
select * from App where
((@CountryId IS NULL) OR (CountryId = @CountryId)) AND
((@StateId IS NULL) OR (StateId = @StateId)) AND
((@Gender IS NULL) OR (GenderTarget = @Gender))
AND (@Age >= AppMinAge OR @Age IS NULL)
AND (@Age<= AppMaxAge OR @Age IS NULL)
Note : *OR* doesn't really help me here

No comments:

Post a Comment