像Google一样的SQL搜索语句?
是否有某种 SQL 语句可以用来对表中的 1 列进行搜索,该列与我正在寻找的内容类似。
就像如果我正在寻找与“汽车”有关的东西,但我将其拼写为“Kar”,它必须返回“汽车”的项目。
或者,
如果我正在寻找“我的公司”并且我将其拼写为“MyCompany”,它仍然必须重新调整“我的公司”。
从 TableName 中选择 *,其中 Column Like '%company%'
将返回“My Company”,但我需要更多,因为用户并不总是知道如何拼写。所以我需要一些更高级的东西,比如一些小的谷歌应用程序或其他东西......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该功能位于文本服务中,因此如果您构建全文搜索索引,您应该能够使用该功能。
看看这里:
http://msdn.microsoft.com/en-us/库/ms187384.aspx
http://msdn.microsoft.com/ en-us/library/ms142571.aspx
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
这是一个相当复杂的问题。快速答案是使用 SQL Server soundex 算法,但它是相当无望的。尝试这个SO答案上的建议。 (更新)
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)
阅读此博文:http://googlesystem.blogspot。 com/2007/04/simplified-version-of-googles-spell.html
您可以使用 SQL 实现此功能,但它不是内置功能。
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.
帮助用户找到他们正在寻找的内容的另一种方法是在搜索字段上实现预先输入。如果用户输入:“我的”,他将得到“我的公司”作为建议,并可能会接受。
您可以使用 jquery 或其他 javascript 库轻松实现类型提前。以下是 jQuery 的预输入插件列表: http://plugins.jquery.com/plugin-tags /提前输入
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
否。全文索引可能会让您更接近,具体取决于您的要求(您正在寻找什么确切功能?)一种选择是使用所需功能滚动您自己的 .NET 程序集,将其添加(创建程序集)到 sql server 并使用那个要搜索的。
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.