質問

I have column store_name (varchar). In that column I have entries like prime sport, best buy... with a space. But when user typed concatenated string like primesport without space I need to show result prime sport. how can I achieve this? Please help me

役に立ちましたか?

解決

SELECT *
FROM TABLE
WHERE replace(store_name, ' ', '') LIKE '%'+@SEARCH+'%' OR  STORE_NAME LIKE '%'+@SEARCH +'%'

他のヒント

Well, I don't have much idea, and even I am searching for it. But may be what I know works for you, You can achieve this by performing different type of string operations:

Mike can be Myke or Myce or Mikke or so on.
Cat an be Kat or katt or catt or so on.

For this you should write a function to generate number of possible strings and then form a SQL Query using all these, and query the database.

A similar kind of search in known as Soundex Search from Oracle and Soundex Search from Microsoft. Have a look of it. this may work.

And overall make use of functions like upper and lower.

Have you tried using replace()

You can replace the white space in the query then use like

SELECT * FROM table WHERE replace(store_name, ' ', '') LIKE '%primesport%'

It will work for entries like 'prime soft' querying with 'primesoft'

Or you can use regex.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top