Reputation: 327
i am making a search for for a website. what i am looking to do is find a simple way to allow for a partial search. something like, if someone searches for 'abc' i want to be able to search of a 66% match.
select [itemNumber]
from [items]
where
([description] like '%a%' and [description] like '%b%' and [description] like '%c%')
or
([description] like '%a%' and [description] like '%b%')
or
([description] like '%a%' and [description] like '%c%')
or
([description] like '%b%' and [description] like '%c%')
is there a simpler way to do this?
Upvotes: 0
Views: 101
Reputation: 22803
I don't know how to make it in single row but this can simplify a little bit:
where [description] Like '%[abc]%' OR
[description] Like '%[ab]%' OR
[description] Like '%[ac]%' OR
[description] Like '%[bc]%' OR
Check this how we can use wildcards in sql server
Upvotes: 1