在SQL Server中进行高级搜索 [英] Advanced search in sql server

查看:90
本文介绍了在SQL Server中进行高级搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

i想要选择表格中的所有记录,如下所示:



如果搜索字符串为i昨天和朋友一起去了超市

i想要丢弃这些话我,对,有,所以剩下的话都是超市昨天的朋友所以我在桌子上搜索对于以下内容:



1-first select * from mytable where title ='昨天我和一位朋友去了超市'整个字符串,



2 - 选择任何标题中包含两个或更多单词的字符串去超市昨天的朋友

无论单词的顺序



3-最后选择任何记录包含昨天去超市的朋友中的任何单词



例如:



i在mytable中有三行:



1-我在超市买单

2-在超市见到你的朋友

3-我去了超市yesterd和朋友一起

4-John去了超市



选择结果必须是:



第一行

我昨天和朋友去了超市(确切地说同样)



第二行或第三行行(包含2个字:去了,超市)

John在第二或第三行行去超市





在超市见到你的朋友 (包含2个单词:朋友,超市,即使顺序不同)


最后一行


我超市(包含1个字:超市)



因此我需要一个高级搜索引擎,但我不想使用临时表,因为我会在许多用户遇到麻烦正在同时搜索



感谢先进的

dears,
i want to select all the the records in the table as the below:

if the search string is "i went to the supermarket yesterday with a friend"
i want to discard these words "i, to, the, with, a" so the remain words are "went supermarket yesterday friend" so i search in the table for the follows:

1-first select * from mytable where title = 'i went to the supermarket yesterday with a friend' the whole string,

2-select any title contains two or more words in the string "went supermarket yesterday friend"
regardless the order of the word

3- at the end select any record contains any word in "went supermarket yesterday friend"

example:

i have three rows in mytable:

1-"i bough a supermarket"
2-"meet your friend in the supermarket"
3-"i went to the supermarket yesterday with a friend"
4-"John went to the supermarket"

the result of the selection must be :

in first row
"i went to the supermarket yesterday with a friend" (exactly same)

in the second or third row (contains 2 words: went, supermarket)
"John went to the supermarket"

in the second or third row
"meet your friend in the supermarket" (contains 2 words: friend, supermarket even if in different order)

in the last row
"i bough a supermarket" (contains 1 word: supermarket )

as a result i need an advanced search engine but i don't want to use temp table because i thing it will make troubles when many users are searching at the same time

thanks on advanced

推荐答案

这不是一项琐碎的工作,你要去o必须认真阅读。

从MSDN开始: http:// msdn.microsoft.com/en-us/library/ms142571.aspx [ ^ ]

然后试试这个: http://ewbi.blogs.com/develops/2007/05/normalizing_sql.html [ ^ ]完成MS链接的所有基础知识。
This is not a trivial job, and you are going to have to do some serious reading.
Start with MSDN: http://msdn.microsoft.com/en-us/library/ms142571.aspx[^]
Then try this: http://ewbi.blogs.com/develops/2007/05/normalizing_sql.html[^] once you have done all the basics from the MS links.


这篇关于在SQL Server中进行高级搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆