<!--
google_ad_client = "pub-4490194096475053";
/* 内容页,300x250,第一屏 */
google_ad_slot = "3685991503";
google_ad_width = 300;
google_ad_height = 250;
// -->
主题: 怎样提取数据库用|隔开的字!
如题:我写入关键字到数据库,多的时候用|隔开了,我提取再做相关文章搜索的时候,我怎么提取用|隔开的文字啊,这样我就好用关键字做搜索啊
回复:
<script language="vbscript">
dim keywords,operator,operend,strsql
keywords="服装|荷花|名牌|中国"
strsql = "select * from table_name where"
operator=" title LIKE '%"
operend="%'"
keywords=Join(Split(keywords,"|"),operend & " OR " & operator)
document.write strsql & operator & keywords & operend
</script>
该查询的用法:
在添加数据记录时可写入多个关键字,关键字与关键字之间用"|"隔开,当然也可以用其它字符,这样就需要修改一下相关的代码了。最后根据所产生的SQL语句即可查询出相关的记录
提取数据库中用|分隔的关键字
本文介绍了一种从数据库中提取使用竖线(|)分隔的关键字的方法,并提供了一个VBScript脚本示例,用于生成SQL查询语句,从而实现对含有多个关键字的数据记录进行有效检索。
1316

被折叠的 条评论
为什么被折叠?



