NicktheNewbie
MIS
Ok,
Need to write a query that will be able to have 3 where clauses... but I have some questions.
3 drop down lists, any of which could have a null value
I need to query based upon the values (or lack thereof) in these fields.
WHERE Category = ISNULL(@Category, Category)
AND Location = ISNULL(@Location, Location)
AND ( FirstName LIKE @FirstSearch + '%'
OR LastName LIKE @LastSearch + '%' )
Is this the proper syntax to ignore a part of a where clause if it has a null value?
Also, I want to be able to allow for a null value in the search field:
if a user specifies a location and category, but doesn't enter anythinging into the searchbar for name, I still want all the records in the specified location and category to show up.
Need to write a query that will be able to have 3 where clauses... but I have some questions.
3 drop down lists, any of which could have a null value
I need to query based upon the values (or lack thereof) in these fields.
WHERE Category = ISNULL(@Category, Category)
AND Location = ISNULL(@Location, Location)
AND ( FirstName LIKE @FirstSearch + '%'
OR LastName LIKE @LastSearch + '%' )
Is this the proper syntax to ignore a part of a where clause if it has a null value?
Also, I want to be able to allow for a null value in the search field:
if a user specifies a location and category, but doesn't enter anythinging into the searchbar for name, I still want all the records in the specified location and category to show up.