|
主题: 请问为什么我做的搜索引擎中不能加空格
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#12003/3/13 21:38:36
是不是因为我用的SQL语句不对,其实我就想做的和SINA SOHU那种在结果中查询类似的功能,空格在此还意味着是 + 关键字的意思....明白了吗?问好好不容易没了,又碰到这种怪胎问题,我的实习之路为何如此艰辛!!!!!!!!!
|
 沉默是金
职务:普通成员
等级:6
金币:11.2
发贴:4357
注册:2004/2/18 11:17:25
|
#22003/3/14 8:53:31
你得用split对你所输入的进行分割来判断是否有空格,然后再进行查找。
难人一个……
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#32003/3/14 15:56:45
老兄: 你为什么每次说的都那么简单!!听不明白呢!(太简单了)我的查询内容里也有空格例如关键字中可以是 'blance sheet' 也可以是'blance'....现在就差这一个问题没解决了,如果解决了,我每天都会给你上香的,谢谢,5D万岁!!!!!!
|
 缺缺
职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
|
#42003/3/14 16:02:01
+,-符号的判断不是sql自己的功能,而是需要自己编代码来做这样的逻辑判断的.
你可以参考一下split的用法.
另外,自己把自己的后面两个帖子删了,被斑竹删就不好了
编辑历史:[这消息被allinhands编辑过(编辑时间2003-03-14 16:05:03)]
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#52003/3/14 23:42:49
函数:split() -------------------------------------------------------------------------------- 正则表达式函数库 split 将字符串依指定的规则切开。 语法: array split(string pattern, string string, int [limit]); 返回值: 数组 函数种类: 资料处理 内容说明 本函数可将字符串依指定的规则分开。切开后的返回值为数组变量。参数 pattern 为指定的规则字符串、参数 string 则为待处理的字符串、参数 limit 可省略,表示欲处理的最多合乎值。值得注意的是本函数的 pattern 参数有区分大小写。 参考 explode() implode() --------------------------------------------------------------------------------
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#62003/3/14 23:48:32
编辑历史:[这消息被iamdaijun编辑过(编辑时间2003-03-15 15:07:18)] [这消息被iamdaijun编辑过(编辑时间2003-03-15 15:08:19)]
|
 5D荣誉斑竹
职务:普通成员
等级:3
金币:10.0
发贴:1480
注册:2002/1/15 11:01:54
|
#72003/3/18 4:26:06
最简单的用法:
strSearch="一 二 三 四"
arrSearch = split(strSearch," ") '////返回的arrSearch为一个数组
For i=0 to Ubound(arrSearch-1) Response.Write(arrSearch(i)&" ") Next
输出结果: 一 二 三 四
没有测试,不知道对不对,大致的意思就是这样. ;)
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#82003/3/18 23:10:15
可不可以用 if _____ then strSearch="一 二 三 四" arrSearch = split(strSearch," ") '////返回的arrSearch为一个数组 For i=0 to Ubound(arrSearch-1) Response.Write(arrSearch(i)&" ") Next else _________ endif ????可以吗?可以的话帮我填一下吧!我很皮厚吧!如果实在不行我只能叫人家不准输入空格了
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#92003/3/19 0:21:28
其实,实话说吧,本人是从事金融业的. 我要做的其实是个金融词汇查询系统,我们单位专门派了好几个人和打字员日夜不停将外国金融词汇(外汇.期货.证券.......),整理出来打成WORD文档,这个系统的使用对象还可以是那些参加CFA(注册金融分析师),因为加入世贸以后上海的金融业,尤其是银行业竞争很激烈,所以需要大量的这方面的人才,而我现在所做的就是帮助他们建立一个大约拥有几千个专业术语的网上查询系统.这个在国内外来说目前都是一个空白(没有骗人),CFA考试是MSBA的核心课程,通过着可拥有AIMR授权的证书.有点像你们计算机行业中的MCSE 所以因该说还是很有开发的意义!不是吗?(并不是闲着无聊) 但是,那么有挑战性的工作却不幸的落到我的头上,当初觉得自己有能力作出这个玩意,可是,一会用DREAMWEAVER MX(照着你们说的做)却乱码后来用FRONTPAGE XP没有乱码,(也许是对ACCESS数据库的支持的好)而且很方便的作出了,就是用: 插入------>数据库------->查询结果 然后一步步像安装一样的就搞定了数据库的连接,顺便还搞定了查询条件(我用的是包含关键字).确实很方便! 然后正当我在暗自为自己的聪明才智感到无比骄傲的同时以及FRONTPAGE XP的傻瓜般的简易操作心存感激之时,我那个可恶的同事问我一个非常可恶的问题,"-------同学为什么我找不到词组?(词组打了空格了,其实他打前半个关键字就足够了,查询出来的结果已经包含他要的结果了,但是也有不希望看见的结果比如,查active portfolio strategy 积极的投资组合策略 查出来的结果是这几条: 1.active portfolio strategy 积极的投资组合策略 XXXXXXXXXXXX 2.active style management 积极的风格管理 XXXXXXXXXXXX 3.active .......................................... XXXXXXXXXXXX 4.active ......................................... XXXXXXXXXXXX 他够吹毛求疵,想要准确的100%的找出来,其实我想这完全没有必要吗?要知道,我当时刚从长年来的郁闷中解放出来....但是我想,也许这是最后一个我要解决的问题,好象也是最难解决的问题了,我发帖已经有5天了,而且刚才好象找到答案了就是你们说的用split()函数..可是我用不来,我不是学计算机方面的,所以现在我只能靠各位5D的朋友们帮帮忙了, ;) 或者你能告诉我在哪本书上,能找到我要的答案.提供一点案例我将不胜感激 感谢那头大熊猫arhui(TMD你不是初学者),还有马屁精allinhands(TMD我灌水要你吼个屁啊),另外deepdark你的LOGO很酷,如果能回答的更加具体一点(啊勒塞是上海人呀,帮帮忙好伐啦?) 为了帮助大家了解我目前的工作状况,我来列举一下有关信息,以供大家切磋
目前的数据库: HANDBOOK.MDB (ACCESS 2000) 连接方式: 我没有采用什么乱七八糟高深的什么ADO,DAO.....(我不懂)都是FRONTPAGE XP帮我搞定的,不需要DSN的那种.直接连数据库 数据库结构: 关键字 2个(够简单吧) EXAMPLE: 1. KEYWORD(查询的字) 2. CONTENT(对应的内容) funds 12b-1基金 (1980年通过)允许的一种..... abnormal returns 超常收益(率) .......................
本人EMAIL: KELLY_0309@HOTMAIL.COM
|
 Mike
职务:版主
等级:6
金币:11.0
发贴:5148
注册:2004/6/10 14:12:22
|
#102003/3/20 18:26:02
The basic syntax for the split command is: split(string,delimiter).
Lets say for example you had a sentence "I Love fish they taste real nice" and you wanted to split the text into individual words and write them out on separate lines like this:
I Love fish they taste real nice
In this case the delimiter you want to use to split the string up would be a space, so your code would look something like this:
'Populate a variable with the sentence strText = "I Love fish they taste real nice"
'Split the sentence into an array arrTemp = split(strText," ")
'Loop through the array and write out the words on separate lines For i = 0 to UBOUND(arrTemp) response.write arrTemp(i) & " " Next
Wow, I hear you cray, very useful but whats it good for? I've found loads of uses for it, but by far the best is for performing searches, lets say we have a free entry text box in which users can enter several keywords separated by commas and the search is looking for ALL the words rather than an exact phrase. This is where the split command comes into its own. Lets say our search box is called "searchtext" and we want to build a SQL query that we can use to open a recordset that looks for all the words in a column called "Keywords" in a table called "SearchTable". The code might look something like this:
'Get the keywords from the form and split them into an array, using the commas as a delimiter strText = Request.Form("searchtext") arrSearch = split(strText,",")
'Build the basic part of the search query (the select statement) strSQL = "select * from SearchTable"
'Loop through the array and add the keywords to the statement For i = 0 to UBOUND(arrSearch) If i = 0 Then 'this is the first item in the array, so include the where statement strSQL = strSQL & " where Keywords like '%" & arrSearch(i) & %'" Else 'This is not the first item, so include an and at the beginning strSQL = strSQL & " and Keywords like '%" & arrSearch(i) & %'" End If Next
If we were using this properly we'd have checks to make sure they'd entered keywords and the like, but you can see how nifty the split command is. 我真的加了可是没有用呀! Textsplit(string,delimiter).
编辑历史:[这消息被iamdaijun编辑过(编辑时间2003-03-20 18:27:38)]
|
 大雪糕
职务:普通成员
等级:2
金币:10.0
发贴:579
注册:2002/2/2 11:30:51
|
#112003/3/20 22:08:41
key="abc+cba+bac" MyArray=Split(key,"+") sql="select xxx,xxx from xxx where xxx='" & MyArray(0) & "'" for i=1 to Ubound(MyArray) sql=sql & " or xxx='" & MyArray(i) & "'" next
|