Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Intelligent Like Query

Author  Topic 

novicenovice
Starting Member

4 Posts

Posted - 2008-06-20 : 06:35:49
SELECT * from table where city like '%woshington%'
Now this would return nothing, as there is no city like woshington. but google find results and ask as r u looking washington. so would u please tell how I may write an intelligent SQL like query

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-06-20 : 06:41:19
You can make use of SOUNDEX() or Difference() function

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

novicenovice
Starting Member

4 Posts

Posted - 2008-06-20 : 06:44:22
I am very new to SQL just like new born baby:). Even not familar with syntax as well. Would you please write complete query. Thanks
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-06-20 : 06:44:36
[code]declare @t table
(
state varchar(100)
)
insert @t
select 'new york' union all
select 'washington' union all
select 'new jersey'

-- using soundex
select * from @t where soundex(state) = soundex('woshington')

-- using difference
select * from @t where difference(state, 'woshington') = 4[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

novicenovice
Starting Member

4 Posts

Posted - 2008-06-20 : 06:57:25
thanks. It works ... But it is too sensitive with sound... I mean in the category column the values was Cloths. I searched with cloth, it provide no results then i searched with clootss. It gives results.

any how. thanks for your prompt help.
Ahmad. Pakistan
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2008-06-20 : 11:19:30
The "CompareText" function on this page should do what you want:
http://sqlblindman.googlepages.com/fuzzysearchalgorithm

e4 d5 xd5 Nf6
Go to Top of Page
   

- Advertisement -