Etienne
Etienne

Reputation: 7191

SQL Search Statement like Google?

Is there some kind of SQL Statement that I can used to do a search on 1 Column in my table that is similar to what I am looking for.

Like if I am looking for something to do with a "Car" but I spell it as "Kar" it must return items of "car".

Or

If I am looking for "My Company" and I spell it as "MyCompany" it must still retun "My Company".

Select * from TableName where Column Like '%company%' will return "My Company" but I need more as the user will not always know how to spell. So I need something more advanced like some small Google App or something...

Upvotes: 3

Views: 2442

Answers (5)

Zephyr
Zephyr

Reputation: 7823

This is quite an involved problem. The quick answer is to use the SQL Server soundex algorithm, but it's pretty hopeless. Try the suggestions on this SO answer. (Updated)

Upvotes: 2

SingleNegationElimination
SingleNegationElimination

Reputation: 156128

Read this blog post: http://googlesystem.blogspot.com/2007/04/simplified-version-of-googles-spell.html

This is something you could implement with SQL, but it's not a built in feature.

Upvotes: 1

Aliostad
Aliostad

Reputation: 81660

That feature is in the text services so if you build a full-text search index, you should be able to use the feature.

Have a look here:

http://msdn.microsoft.com/en-us/library/ms187384.aspx

http://msdn.microsoft.com/en-us/library/ms142571.aspx

Upvotes: 2

Booji Boy
Booji Boy

Reputation: 4582

No. A full text index might get you closer, depending on your requirements (what exact features are you looking for?) One option would be roll you own .NET assembly with the desired features add it (CREATE ASSEMBLY) to sql server and use that to search.

Upvotes: 0

Merrimack
Merrimack

Reputation: 1726

Another way to help you users find what they are looking for is to implement type-ahead on the search field. If the user type: "my" he will get "My Company" as a suggestion and likely go with that.

You can easily implement type ahead using jquery or other javascript libraries. Here's a list of type ahead plugins for jQuery: http://plugins.jquery.com/plugin-tags/typeahead

Upvotes: 0

Related Questions