Help in designing search query
-
Hi all, Table schema empid primary key emp_name emp_age emp_skills emp_Isactive I am storing multiple skills of a customer in same column separated with commas.I have designed a search form where in the employer enters skills in search box separated using commas. I want to match these skills irrespective of commas. for this purpose i used a stored proc and passed skills as parameters select skill from tbljob where skill like '%'+ISNULL(@skill1,skill)+'%' or skill like '%'+ISNULL(@skill2,skill)+'%' or skill like '%'+ISNULL(@skill3,skill)+'%' but if one of the skill 1,2,3 is null ie if user enters only 1 or 2 , it returns all rows because the other condition is always true . How can i use "OR" with other statements so that it works out
-
Hi all, Table schema empid primary key emp_name emp_age emp_skills emp_Isactive I am storing multiple skills of a customer in same column separated with commas.I have designed a search form where in the employer enters skills in search box separated using commas. I want to match these skills irrespective of commas. for this purpose i used a stored proc and passed skills as parameters select skill from tbljob where skill like '%'+ISNULL(@skill1,skill)+'%' or skill like '%'+ISNULL(@skill2,skill)+'%' or skill like '%'+ISNULL(@skill3,skill)+'%' but if one of the skill 1,2,3 is null ie if user enters only 1 or 2 , it returns all rows because the other condition is always true . How can i use "OR" with other statements so that it works out
change your
ISNULL()
NULL result to something that can't be located:ISNULL(@skill1,'&^%$')